[#283] cli: Move control healthcheck command under control ir #368
3 changed files with 54 additions and 33 deletions
|
@ -1,15 +1,10 @@
|
||||||
package control
|
package control
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
|
||||||
|
|
||||||
rawclient "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
rawclient "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
||||||
ircontrol "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
|
||||||
ircontrolsrv "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,8 +14,8 @@ const (
|
||||||
|
|
||||||
var healthCheckCmd = &cobra.Command{
|
var healthCheckCmd = &cobra.Command{
|
||||||
Use: "healthcheck",
|
Use: "healthcheck",
|
||||||
Short: "Health check of the FrostFS node",
|
Short: "Health check for FrostFS storage nodes",
|
||||||
Long: "Health check of the FrostFS node. Checks storage node by default, use --ir flag to work with Inner Ring.",
|
Long: "Health check for FrostFS storage nodes.",
|
||||||
Run: healthCheck,
|
Run: healthCheck,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,18 +24,18 @@ func initControlHealthCheckCmd() {
|
||||||
|
|
||||||
flags := healthCheckCmd.Flags()
|
flags := healthCheckCmd.Flags()
|
||||||
flags.Bool(healthcheckIRFlag, false, "Communicate with IR node")
|
flags.Bool(healthcheckIRFlag, false, "Communicate with IR node")
|
||||||
|
_ = flags.MarkDeprecated(healthcheckIRFlag, "for health check of inner ring nodes, use the 'control ir healthcheck' command instead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func healthCheck(cmd *cobra.Command, _ []string) {
|
func healthCheck(cmd *cobra.Command, args []string) {
|
||||||
pk := key.Get(cmd)
|
|
||||||
|
|
||||||
cli := getClient(cmd, pk)
|
|
||||||
|
|
||||||
if isIR, _ := cmd.Flags().GetBool(healthcheckIRFlag); isIR {
|
if isIR, _ := cmd.Flags().GetBool(healthcheckIRFlag); isIR {
|
||||||
healthCheckIR(cmd, pk, cli)
|
irHealthCheck(cmd, args)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pk := key.Get(cmd)
|
||||||
|
cli := getClient(cmd, pk)
|
||||||
|
|
||||||
req := new(control.HealthCheckRequest)
|
req := new(control.HealthCheckRequest)
|
||||||
req.SetBody(new(control.HealthCheckRequest_Body))
|
req.SetBody(new(control.HealthCheckRequest_Body))
|
||||||
|
|
||||||
|
@ -59,23 +54,3 @@ func healthCheck(cmd *cobra.Command, _ []string) {
|
||||||
cmd.Printf("Network status: %s\n", resp.GetBody().GetNetmapStatus())
|
cmd.Printf("Network status: %s\n", resp.GetBody().GetNetmapStatus())
|
||||||
cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus())
|
cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
func healthCheckIR(cmd *cobra.Command, key *ecdsa.PrivateKey, c *client.Client) {
|
|
||||||
req := new(ircontrol.HealthCheckRequest)
|
|
||||||
|
|
||||||
req.SetBody(new(ircontrol.HealthCheckRequest_Body))
|
|
||||||
|
|
||||||
err := ircontrolsrv.SignMessage(key, req)
|
|
||||||
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
|
||||||
|
|
||||||
var resp *ircontrol.HealthCheckResponse
|
|
||||||
err = c.ExecRaw(func(client *rawclient.Client) error {
|
|
||||||
resp, err = ircontrol.HealthCheck(client, req)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
|
||||||
|
|
||||||
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
|
||||||
|
|
||||||
cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus())
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,9 @@ var irCmd = &cobra.Command{
|
||||||
func initControlIRCmd() {
|
func initControlIRCmd() {
|
||||||
irCmd.AddCommand(tickEpochCmd)
|
irCmd.AddCommand(tickEpochCmd)
|
||||||
irCmd.AddCommand(removeNodeCmd)
|
irCmd.AddCommand(removeNodeCmd)
|
||||||
|
irCmd.AddCommand(irHealthCheckCmd)
|
||||||
|
|
||||||
initControlIRTickEpochCmd()
|
initControlIRTickEpochCmd()
|
||||||
initControlIRRemoveNodeCmd()
|
initControlIRRemoveNodeCmd()
|
||||||
|
initControlIRHealthCheckCmd()
|
||||||
}
|
}
|
||||||
|
|
44
cmd/frostfs-cli/modules/control/ir_healthcheck.go
Normal file
44
cmd/frostfs-cli/modules/control/ir_healthcheck.go
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
package control
|
||||||
|
|
||||||
|
import (
|
||||||
|
rawclient "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"
|
||||||
|
ircontrol "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
||||||
|
ircontrolsrv "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var irHealthCheckCmd = &cobra.Command{
|
||||||
|
Use: "healthcheck",
|
||||||
|
Short: "Health check for FrostFS inner ring nodes",
|
||||||
|
Long: "Health check for FrostFS inner ring nodes.",
|
||||||
|
Run: irHealthCheck,
|
||||||
|
}
|
||||||
|
|
||||||
|
func initControlIRHealthCheckCmd() {
|
||||||
|
initControlFlags(irHealthCheckCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func irHealthCheck(cmd *cobra.Command, _ []string) {
|
||||||
|
pk := key.Get(cmd)
|
||||||
|
cli := getClient(cmd, pk)
|
||||||
|
|
||||||
|
req := new(ircontrol.HealthCheckRequest)
|
||||||
|
|
||||||
|
req.SetBody(new(ircontrol.HealthCheckRequest_Body))
|
||||||
|
|
||||||
|
err := ircontrolsrv.SignMessage(pk, req)
|
||||||
|
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
||||||
|
|
||||||
|
var resp *ircontrol.HealthCheckResponse
|
||||||
|
err = cli.ExecRaw(func(client *rawclient.Client) error {
|
||||||
|
resp, err = ircontrol.HealthCheck(client, req)
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
||||||
|
|
||||||
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
||||||
|
|
||||||
|
cmd.Printf("Health status: %s\n", resp.GetBody().GetHealthStatus())
|
||||||
|
}
|
Loading…
Reference in a new issue