[#1043] cli: Add reset evacuation status command

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-03-13 10:40:44 +03:00 committed by Evgenii Stratonikov
parent 31e2396a5f
commit 17f5463389
3 changed files with 67 additions and 19 deletions

View file

@ -53,6 +53,13 @@ var stopEvacuationShardCmd = &cobra.Command{
Run: stopEvacuateShardStatus, Run: stopEvacuateShardStatus,
} }
var resetEvacuationStatusShardCmd = &cobra.Command{
Use: "reset",
Short: "Reset evacuate objects from shard status",
Long: "Reset evacuate objects from shard to other shards status",
Run: resetEvacuateShardStatus,
}
func startEvacuateShard(cmd *cobra.Command, _ []string) { func startEvacuateShard(cmd *cobra.Command, _ []string) {
pk := key.Get(cmd) pk := key.Get(cmd)
@ -152,6 +159,29 @@ func stopEvacuateShardStatus(cmd *cobra.Command, _ []string) {
cmd.Println("Evacuation stopped.") cmd.Println("Evacuation stopped.")
} }
func resetEvacuateShardStatus(cmd *cobra.Command, _ []string) {
pk := key.Get(cmd)
req := &control.ResetShardEvacuationStatusRequest{
Body: &control.ResetShardEvacuationStatusRequest_Body{},
}
signRequest(cmd, pk, req)
cli := getClient(cmd, pk)
var resp *control.ResetShardEvacuationStatusResponse
var err error
err = cli.ExecRaw(func(client *client.Client) error {
resp, err = control.ResetShardEvacuationStatus(client, req)
return err
})
commonCmd.ExitOnErr(cmd, "Reset shards evacuation status failed, rpc error: %w", err)
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
cmd.Println("Shards evacuation status has been reset.")
}
func waitEvacuateCompletion(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *clientSDK.Client, printProgress, printCompleted bool) { func waitEvacuateCompletion(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *clientSDK.Client, printProgress, printCompleted bool) {
const statusPollingInterval = 1 * time.Second const statusPollingInterval = 1 * time.Second
const reportIntervalSeconds = 5 const reportIntervalSeconds = 5
@ -323,10 +353,12 @@ func initControlEvacuationShardCmd() {
evacuationShardCmd.AddCommand(startEvacuationShardCmd) evacuationShardCmd.AddCommand(startEvacuationShardCmd)
evacuationShardCmd.AddCommand(getEvacuationShardStatusCmd) evacuationShardCmd.AddCommand(getEvacuationShardStatusCmd)
evacuationShardCmd.AddCommand(stopEvacuationShardCmd) evacuationShardCmd.AddCommand(stopEvacuationShardCmd)
evacuationShardCmd.AddCommand(resetEvacuationStatusShardCmd)
initControlStartEvacuationShardCmd() initControlStartEvacuationShardCmd()
initControlFlags(getEvacuationShardStatusCmd) initControlFlags(getEvacuationShardStatusCmd)
initControlFlags(stopEvacuationShardCmd) initControlFlags(stopEvacuationShardCmd)
initControlFlags(resetEvacuationStatusShardCmd)
} }
func initControlStartEvacuationShardCmd() { func initControlStartEvacuationShardCmd() {

View file

@ -20,6 +20,8 @@ Only one running evacuation process is allowed on the node at a time.
`frostfs-cli control shards evacuation status` prints evacuation process status. `frostfs-cli control shards evacuation status` prints evacuation process status.
`frostfs-cli control shards evacuation reset` resets evacuation process status.
See commands `--help` output for detailed description. See commands `--help` output for detailed description.
## Examples ## Examples

View file

@ -17,6 +17,7 @@ const (
rpcEvacuateShard = "EvacuateShard" rpcEvacuateShard = "EvacuateShard"
rpcStartShardEvacuation = "StartShardEvacuation" rpcStartShardEvacuation = "StartShardEvacuation"
rpcGetShardEvacuationStatus = "GetShardEvacuationStatus" rpcGetShardEvacuationStatus = "GetShardEvacuationStatus"
rpcResetShardEvacuationStatus = "ResetShardEvacuationStatus"
rpcStopShardEvacuation = "StopShardEvacuation" rpcStopShardEvacuation = "StopShardEvacuation"
rpcFlushCache = "FlushCache" rpcFlushCache = "FlushCache"
rpcDoctor = "Doctor" rpcDoctor = "Doctor"
@ -190,6 +191,19 @@ func StopShardEvacuation(cli *client.Client, req *StopShardEvacuationRequest, op
return wResp.message, nil return wResp.message, nil
} }
// ResetShardEvacuationStatus executes ControlService.ResetShardEvacuationStatus RPC.
func ResetShardEvacuationStatus(cli *client.Client, req *ResetShardEvacuationStatusRequest, opts ...client.CallOption) (*ResetShardEvacuationStatusResponse, error) {
wResp := newResponseWrapper[ResetShardEvacuationStatusResponse]()
wReq := &requestWrapper{m: req}
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcResetShardEvacuationStatus), wReq, wResp, opts...)
if err != nil {
return nil, err
}
return wResp.message, nil
}
// FlushCache executes ControlService.FlushCache RPC. // FlushCache executes ControlService.FlushCache RPC.
func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallOption) (*FlushCacheResponse, error) { func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallOption) (*FlushCacheResponse, error) {
wResp := newResponseWrapper[FlushCacheResponse]() wResp := newResponseWrapper[FlushCacheResponse]()