opencurve / curve

Curve is a sandbox project hosted by the CNCF Foundation. It's cloud-native, high-performance, and easy to operate. Curve is an open-source distributed storage system for block and shared file storage.
https://opencurve.io
Apache License 2.0
2.33k stars 522 forks source link

[tools-v2] The command "curve bs check chunkserver" works incorrectly #2922

Open zhengweizhu opened 11 months ago

zhengweizhu commented 11 months ago

Describe the bug (描述bug) The command "curve bs check chunkserver --chunkserverid n" works in this way:

  1. get all copysets in the chunkserver specified
  2. make a subcommand "CopysetCommand" with slice param for all copysetid and logicpoolid
  3. get chunkserver list for each copyset
  4. call CopysetCommand.cmd.ParseFlag with param "--peers"
  5. make a subcommand "GetCopysetStatusCommand" for each copyset and duplicate param "--peers" from CopysetCommand.cmd, then visit each chunkserver specified in param "--peers" to get copyset status

The problem is that in step4, each call to CopysetCommand.cmd.ParseFlag only adds param (but no clean), which leads to param "--peers" for command "GetCopysetStatusCommand" longer and longer. The result is that visiting to most chunkservers is unnecessary and spends too much time, and the output of the command "curve bs check chunkserver" may be misleading.

By the way, there is also another bug where the output of this command is wrongly missing value "HEALTHYCOUNT UNHEALTHYCOUNT UNHEALTHYRATIO"

To Reproduce (复现方法) curve bs check chunkserver --chunkserverid 1 --verbose # must reproduce. you can see the detail by verbose log

Expected behavior (期望行为) No unnecessary visit to chunkservers and the command output is correct.

Versions (各种版本) OS: Compiler: branch: commit id:

Additional context/screenshots (更多上下文/截图) curve-cli

zhengweizhu commented 11 months ago

It's fixed by me. Glad to make a pr.

caoxianfei1 commented 11 months ago

It's fixed by me. Glad to make a pr.

Welcome!