From daa254d72b616f920a69a5640fb99332d4f5db50 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 29 May 2023 18:44:46 +0300 Subject: [PATCH 1/2] [#402] cli: Add estimated evacuation time left Signed-off-by: Dmitrii Stepanov --- cmd/frostfs-cli/modules/control/evacuation.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/frostfs-cli/modules/control/evacuation.go b/cmd/frostfs-cli/modules/control/evacuation.go index 45152fa0a..4eb6505cf 100644 --- a/cmd/frostfs-cli/modules/control/evacuation.go +++ b/cmd/frostfs-cli/modules/control/evacuation.go @@ -212,9 +212,28 @@ func printStatus(cmd *cobra.Command, resp *control.GetShardEvacuationStatusRespo appendError(sb, resp) appendStartedAt(sb, resp) appendDuration(sb, resp) + appendEstimation(sb, resp) 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) { if resp.GetBody().GetDuration() != nil { duration := time.Second * time.Duration(resp.GetBody().GetDuration().GetSeconds()) -- 2.45.2 From 370cd1775fdda58ac57f6ab677cc397a7d5d5c29 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Tue, 30 May 2023 10:11:08 +0300 Subject: [PATCH 2/2] [#402] doc: Update evacuation docs Add estimated time left output to examples. Signed-off-by: Dmitrii Stepanov --- docs/evacuation.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/evacuation.md b/docs/evacuation.md index 5befad164..9bfa0e214 100644 --- a/docs/evacuation.md +++ b/docs/evacuation.md @@ -39,15 +39,15 @@ Shard evacuation has been successfully started. frostfs-cli control shards evacuation status --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json Enter password > -Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: running. Evacuated 14 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:00:03. +Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: running. Evacuated 14 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:00:03. Estimated time left: 2 minutes. frostfs-cli control shards evacuation status --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json Enter password > -Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: running. Evacuated 23 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:00:05. +Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: running. Evacuated 23 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:01:05. Estimated time left: 1 minutes. frostfs-cli control shards evacuation status --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json Enter password > -Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: completed. Evacuated 61 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:00:13. +Shard IDs: 8kEBwtvKLU3Hva3PaaodUi. Status: completed. Evacuated 61 object out of 61, failed to evacuate 0 objects. Started at: 2023-05-10T10:13:06Z UTC. Duration: 00:02:13. ``` ### Stop running evacuation process @@ -58,7 +58,7 @@ Shard evacuation has been successfully started. frostfs-cli control shards evacuation status --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json Enter password > -Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 15 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:15:47Z UTC. Duration: 00:00:03. +Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 15 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:15:47Z UTC. Duration: 00:00:03. Estimated time left: 0 minutes. frostfs-cli control shards evacuation stop --endpoint s01.frostfs.devenv:8081 --wallet ./../frostfs-dev-env/services/storage/wallet01.json Enter password > @@ -75,9 +75,9 @@ frostfs-cli control shards evacuation start --endpoint s01.frostfs.devenv:8081 - Enter password > Shard evacuation has been successfully started. Progress will be reported every 5 seconds. -Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 18 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:04. -Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 43 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:09. -Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 68 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:14. +Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 18 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:04. Estimated time left: 0 minutes. +Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 43 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:09. Estimated time left: 0 minutes. +Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Status: running. Evacuated 68 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:14. Estimated time left: 0 minutes. Shard evacuation has been completed. Shard IDs: 54Y8aot9uc7BSadw2XtYr3. Evacuated 73 object out of 73, failed to evacuate 0 objects. Started at: 2023-05-10T10:18:42Z UTC. Duration: 00:00:14. ``` -- 2.45.2