forked from TrueCloudLab/frostfs-node
Airat Arifullin
9b13a18aac
* Update version within go.mod; * Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api instead. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package control
|
|
|
|
import (
|
|
"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"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
|
"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")
|
|
}
|