forked from TrueCloudLab/frostfs-node
Aleksey Savchuk
b9284604d9
We have several ways to specify the `rpc-endpoint`: with a flag, with a single config file or multiple files. Before, the `rpc-endpoint` flag was marked as required. Because `cobra` checked the required flag presence first, it prevented specifying `rpc-endpoint` with a config file. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package tree
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
|
|
"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)
|
|
}
|
|
|
|
func healthcheck(cmd *cobra.Command, _ []string) {
|
|
pk := key.GetOrGenerate(cmd)
|
|
ctx, cancel := contextWithTimeout(cmd)
|
|
defer cancel()
|
|
|
|
cli, err := _client()
|
|
commonCmd.ExitOnErr(cmd, "failed to create client: %w", err)
|
|
|
|
req := &tree.HealthcheckRequest{
|
|
Body: &tree.HealthcheckRequest_Body{},
|
|
}
|
|
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
|
|
|
_, err = cli.Healthcheck(ctx, req)
|
|
commonCmd.ExitOnErr(cmd, "failed to call healthcheck: %w", err)
|
|
|
|
common.PrintVerbose(cmd, "Successful healthcheck invocation.")
|
|
}
|