forked from TrueCloudLab/frostfs-node
[#402] cli: Add estimated evacuation time left
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>logs-linter
parent
ebcc8afbee
commit
f64322576a
|
@ -212,9 +212,28 @@ func printStatus(cmd *cobra.Command, resp *control.GetShardEvacuationStatusRespo
|
||||||
appendError(sb, resp)
|
appendError(sb, resp)
|
||||||
appendStartedAt(sb, resp)
|
appendStartedAt(sb, resp)
|
||||||
appendDuration(sb, resp)
|
appendDuration(sb, resp)
|
||||||
|
appendEstimation(sb, resp)
|
||||||
cmd.Println(sb.String())
|
cmd.Println(sb.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func appendEstimation(sb *strings.Builder, resp *control.GetShardEvacuationStatusResponse) {
|
||||||
|
if resp.GetBody().GetStatus() != control.GetShardEvacuationStatusResponse_Body_RUNNING ||
|
||||||
|
resp.GetBody().GetDuration() == nil ||
|
||||||
|
resp.GetBody().GetTotal() == 0 ||
|
||||||
|
resp.GetBody().GetEvacuated()+resp.GetBody().GetFailed() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
durationSeconds := float64(resp.GetBody().GetDuration().GetSeconds())
|
||||||
|
evacuated := float64(resp.GetBody().GetEvacuated() + resp.GetBody().GetFailed())
|
||||||
|
avgObjEvacuationTimeSeconds := durationSeconds / evacuated
|
||||||
|
objectsLeft := float64(resp.GetBody().GetTotal()) - evacuated
|
||||||
|
leftSeconds := avgObjEvacuationTimeSeconds * objectsLeft
|
||||||
|
leftMinutes := int(leftSeconds / 60)
|
||||||
|
|
||||||
|
sb.WriteString(fmt.Sprintf(" Estimated time left: %d minutes.", leftMinutes))
|
||||||
|
}
|
||||||
|
|
||||||
func appendDuration(sb *strings.Builder, resp *control.GetShardEvacuationStatusResponse) {
|
func appendDuration(sb *strings.Builder, resp *control.GetShardEvacuationStatusResponse) {
|
||||||
if resp.GetBody().GetDuration() != nil {
|
if resp.GetBody().GetDuration() != nil {
|
||||||
duration := time.Second * time.Duration(resp.GetBody().GetDuration().GetSeconds())
|
duration := time.Second * time.Duration(resp.GetBody().GetDuration().GetSeconds())
|
||||||
|
|
Loading…
Reference in New Issue