-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] tools-v2: add bs status cluster #2530
[feat] tools-v2: add bs status cluster #2530
Conversation
cicheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run fail
curve bs status cluster
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xec8ef8]
goroutine 1 [running]:
github.com/opencurve/curve/tools-v2/pkg/cli/command/curvebs/status/cluster.(*ClusterCommand).RunCommand(0xc0001b89a0, 0xc0004ddb00, {0x1795258, 0x0, 0x0})
/home/******/code/curve-backup/tools-v2/pkg/cli/command/curvebs/status/cluster/cluster.go:112 +0x238
tools-v2/internal/error/error.go
Outdated
@@ -459,6 +459,9 @@ var ( | |||
ErrBsListScanStatus = func() *CmdError { | |||
return NewInternalCmdError(66, "list scan-status fail, err: %s") | |||
} | |||
ErrBsListSpaceStatus = func() *CmdError { | |||
return NewInternalCmdError(66, "list space status fail, err: %s") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NewInternalCmdError(66, "list space status fail, err: %s") | |
return NewInternalCmdError(67, "list space status fail, err: %s") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job
@@ -187,3 +188,20 @@ func (sCmd *SpaceCommand) RunCommand(cmd *cobra.Command, args []string) error { | |||
func (sCmd *SpaceCommand) ResultPlainOutput() error { | |||
return output.FinalCmdOutputPlain(&sCmd.FinalCurveCmd) | |||
} | |||
|
|||
func GetSpaceStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return *tablewriter.Table
is ugly, user can use sCmd.Result
by parsing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does mean? cmd.Result is all rows not a table obj and can not render it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does mean? cmd.Result is all rows not a table obj and can not render it directly.
The table object is a list, and it is very ugly to match.
@@ -120,3 +121,19 @@ func NewStatusChunkServerCommand() *ChunkServerCommand { | |||
func NewChunkServerCommand() *cobra.Command { | |||
return NewStatusChunkServerCommand().Cmd | |||
} | |||
|
|||
func GetChunkserverStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -238,3 +242,19 @@ func NewStatusClientCommand() *ClientCommand { | |||
basecmd.NewFinalCurveCli(&clientCmd.FinalCurveCmd, clientCmd) | |||
return clientCmd | |||
} | |||
|
|||
func GetClientStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -92,9 +94,7 @@ func (cCmd *ClientCommand) Init(cmd *cobra.Command, args []string) error { | |||
} | |||
|
|||
if len((*results).([]map[string]string)) == 0 { | |||
retErr := cmderror.ErrBsGetClientStatus() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this error number in tools-v2/internal/error/error.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The err code is used by func GetClientStatus.
@@ -123,6 +123,10 @@ func (cCmd *ClientCommand) Print(cmd *cobra.Command, args []string) error { | |||
} | |||
|
|||
func (cCmd *ClientCommand) RunCommand(cmd *cobra.Command, args []string) error { | |||
if len(cCmd.metrics) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when users use this command directly(he don't create any client), they will get nothings by this way. This is strange for users.
} | ||
|
||
func (cCmd *ClusterCommand) AddFlags() { | ||
config.AddRpcRetryTimesFlag(cCmd.Cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all sub-command flags ought to add this command.
@@ -104,3 +105,19 @@ func NewStatusCopysetCommand() *CopysetCommand { | |||
basecmd.NewFinalCurveCli(©setCmd.FinalCurveCmd, copysetCmd) | |||
return copysetCmd | |||
} | |||
|
|||
func GetCopysetsStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -204,7 +205,7 @@ func NewStatusEtcdCommand() *EtcdCommand { | |||
return etcdCmd | |||
} | |||
|
|||
func GetEtcdStatus(caller *cobra.Command) (*interface{}, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { | |||
func GetEtcdStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cyber-SiKu please take a look this change. It's conflicting with what we discussed earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cyber-SiKu please take a look this change. It's conflicting with what we discussed earlier.
Indeed, it seems strange to directly return a table here. I am thinking about whether this is possible? Directly synchronize the status cluster output format to the subcommand instead of simply setting it to noout? Calling this command in this way also has output, but the status cluster only cares about the inspection results of this step? But in this case, the output in jason format is difficult to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why feel strange? I think that it should be understandable if the output of a command corresponds to a table object. status cluster
is collection of these tables. The cmd.Result is all rows that seems like need to combine them into a table for output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Xinlong-Chen @caoxianfei1
At present, the output of the status cluster is too much, and it is difficult to recognize if the table is directly output. Can you combine the output like this:
services
role | leader | online | offline |
---|---|---|---|
mds | |||
etcd | |||
snapshot | |||
chunkserver | - |
copyset
total | ok | warn | error |
---|---|---|---|
space
... | ... | ... |
---|---|---|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I think both methods are ok.
@@ -195,7 +196,7 @@ func NewStatusMdsCommand() *MdsCommand { | |||
return mdsCmd | |||
} | |||
|
|||
func GetMdsStatus(caller *cobra.Command) (*interface{}, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { | |||
func GetMdsStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -205,7 +206,7 @@ func NewStatusSnapshotCommand() *SnapshotCommand { | |||
return snapshotCmd | |||
} | |||
|
|||
func GetSnapshotStatus(caller *cobra.Command) (*interface{}, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { | |||
func GetSnapshotStatus(caller *cobra.Command) (*interface{}, *tablewriter.Table, *cmderror.CmdError, cobrautil.ClUSTER_HEALTH_STATUS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
for key, function := range cCmd.type2Func { | ||
result, table, err, health := function(cmd) | ||
cCmd.type2Table[key] = table | ||
results[key] = *result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case where result is nil is not handled.
} | ||
finalErr := cmderror.MergeCmdErrorExceptSuccess(errs) | ||
cCmd.Error = finalErr | ||
results["health"] = cobrautil.ClusterHealthStatus_Str[int32(cCmd.health)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the definition of the constant in cobrautil.
03e7029
to
27fbff4
Compare
94f86e7
to
ca20577
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cicheck |
@Xinlong-Chen you can take a look. |
@Xinlong-Chen PTAL? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still have some small questions~
retErr.Format(err.Error()) | ||
return nil, retErr, cobrautil.HEALTH_ERROR | ||
} | ||
fmt.Sprintln(sCmd.Result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can delete debug command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ca20577
to
6ae4f8b
Compare
Signed-off-by: caoxianfei1 <caoxianfei@corp.netease.com>
6ae4f8b
to
2e56ee3
Compare
cicheck |
What problem does this PR solve?
Issue Number: #xxx
Problem Summary:
What is changed and how it works?
What's Changed:
How it Works:
curve bs status cluster
The output is as follows:
Services:
10.0.0.3:23790
10.0.0.3:6700
10.0.0.2:8200
10.0.0.3:8200
10.0.0.3:5555
Copyset:
Space:
Cluster health is: ok
Side effects(Breaking backward compatibility? Performance regression?):
Check List