2023-07-11 09:43:48 +00:00
|
|
|
package tree
|
|
|
|
|
|
|
|
import (
|
2023-07-11 09:36:33 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
2023-07-11 09:43:48 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
|
|
"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/tree"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var healthcheckCmd = &cobra.Command{
|
|
|
|
Use: "healthcheck",
|
|
|
|
Short: "Check tree service availability",
|
|
|
|
Run: healthcheck,
|
|
|
|
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
|
|
|
|
commonflags.Bind(cmd)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func initHealthcheckCmd() {
|
|
|
|
commonflags.Init(healthcheckCmd)
|
|
|
|
ff := healthcheckCmd.Flags()
|
|
|
|
_ = cobra.MarkFlagRequired(ff, commonflags.RPC)
|
|
|
|
}
|
|
|
|
|
|
|
|
func healthcheck(cmd *cobra.Command, _ []string) {
|
|
|
|
pk := key.GetOrGenerate(cmd)
|
2024-09-13 08:32:03 +00:00
|
|
|
ctx, cancel := contextWithTimeout(cmd)
|
|
|
|
defer cancel()
|
2023-07-11 09:43:48 +00:00
|
|
|
|
2024-09-13 08:32:03 +00:00
|
|
|
cli, err := _client()
|
2023-07-11 09:36:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "failed to create client: %w", err)
|
2023-07-11 09:43:48 +00:00
|
|
|
|
|
|
|
req := &tree.HealthcheckRequest{
|
|
|
|
Body: &tree.HealthcheckRequest_Body{},
|
|
|
|
}
|
2023-07-11 09:36:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
2023-07-11 09:43:48 +00:00
|
|
|
|
|
|
|
_, err = cli.Healthcheck(ctx, req)
|
2023-07-11 09:36:33 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "failed to call healthcheck: %w", err)
|
2023-07-11 09:43:48 +00:00
|
|
|
|
2023-07-11 09:36:33 +00:00
|
|
|
common.PrintVerbose(cmd, "Successful healthcheck invocation.")
|
2023-07-11 09:43:48 +00:00
|
|
|
}
|