forked from TrueCloudLab/frostfs-node
[#191] cli: Add control shards doctor
command
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
0b9622c418
commit
b689027d57
2 changed files with 55 additions and 0 deletions
53
cmd/frostfs-cli/modules/control/doctor.go
Normal file
53
cmd/frostfs-cli/modules/control/doctor.go
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package control
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
concurrencyFlag = "concurrency"
|
||||||
|
removeDuplicatesFlag = "remove-duplicates"
|
||||||
|
)
|
||||||
|
|
||||||
|
var doctorCmd = &cobra.Command{
|
||||||
|
Use: "doctor",
|
||||||
|
Short: "Restructure node's storage",
|
||||||
|
Long: "Restructure node's storage",
|
||||||
|
Run: doctor,
|
||||||
|
}
|
||||||
|
|
||||||
|
func doctor(cmd *cobra.Command, _ []string) {
|
||||||
|
pk := key.Get(cmd)
|
||||||
|
|
||||||
|
req := &control.DoctorRequest{Body: new(control.DoctorRequest_Body)}
|
||||||
|
req.Body.Concurrency, _ = cmd.Flags().GetUint32(concurrencyFlag)
|
||||||
|
req.Body.RemoveDuplicates, _ = cmd.Flags().GetBool(removeDuplicatesFlag)
|
||||||
|
|
||||||
|
signRequest(cmd, pk, req)
|
||||||
|
|
||||||
|
cli := getClient(cmd, pk)
|
||||||
|
|
||||||
|
var resp *control.DoctorResponse
|
||||||
|
var err error
|
||||||
|
err = cli.ExecRaw(func(client *client.Client) error {
|
||||||
|
resp, err = control.Doctor(client, req)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
cmd.Println("Operation has finished.")
|
||||||
|
}
|
||||||
|
|
||||||
|
func initControlDoctorCmd() {
|
||||||
|
initControlFlags(doctorCmd)
|
||||||
|
|
||||||
|
ff := doctorCmd.Flags()
|
||||||
|
ff.Uint32(concurrencyFlag, 0, "Number of parallel threads to use")
|
||||||
|
ff.Bool(removeDuplicatesFlag, false, "Remove duplicate objects")
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ func initControlShardsCmd() {
|
||||||
shardsCmd.AddCommand(restoreShardCmd)
|
shardsCmd.AddCommand(restoreShardCmd)
|
||||||
shardsCmd.AddCommand(evacuateShardCmd)
|
shardsCmd.AddCommand(evacuateShardCmd)
|
||||||
shardsCmd.AddCommand(flushCacheCmd)
|
shardsCmd.AddCommand(flushCacheCmd)
|
||||||
|
shardsCmd.AddCommand(doctorCmd)
|
||||||
|
|
||||||
initControlShardsListCmd()
|
initControlShardsListCmd()
|
||||||
initControlSetShardModeCmd()
|
initControlSetShardModeCmd()
|
||||||
|
@ -24,4 +25,5 @@ func initControlShardsCmd() {
|
||||||
initControlRestoreShardCmd()
|
initControlRestoreShardCmd()
|
||||||
initControlEvacuateShardCmd()
|
initControlEvacuateShardCmd()
|
||||||
initControlFlushCacheCmd()
|
initControlFlushCacheCmd()
|
||||||
|
initControlDoctorCmd()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue