Skip to content
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

CurveBs|tools-v2|rebuild check-consistency,list may-broken-vol, check-chunkserver #2132

Closed
wants to merge 3 commits into from

Conversation

jolly-sy
Copy link
Contributor

@jolly-sy jolly-sy commented Dec 3, 2022

the content of this pr is about rebuilding three command :check-consistency,list may-broken-vol, check-chunkserver

check-consistency:
image

list may broken vol:
image

check- chunkserver
image

@jolly-sy jolly-sy force-pushed the bsTool branch 2 times, most recently from 5a31ea7 to 9d0426e Compare December 4, 2022 03:20
@jolly-sy jolly-sy force-pushed the bsTool branch 2 times, most recently from 5be2154 to 41e77ac Compare December 13, 2022 05:50
@jolly-sy
Copy link
Contributor Author

cicheck

@Cyber-SiKu
Copy link
Contributor

Cyber-SiKu commented Dec 13, 2022

All output should be printed using tableNew, please do not print by yourself, this output is not friendly.
If you need to print multiple tables, please consider splitting them into multiple commands and pay attention to the uniform style of the tables.


所有的输出都应该使用tableNew 打印,请不要自行打印,这样输出不友好。
如果需要打印多个表格,请考虑拆分成多个命令,注意表格风格的统一。

@@ -357,7 +357,7 @@ var (
return NewInternalCmdError(36, "get time of day fail, the error is: %s")
}
ErrBsGetFileInfo = func() *CmdError {
return NewInternalCmdError(37, "get file info fail, the error is: %s")
return NewInternalCmdError(37, "%s")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete this?

coding error, fix

Comment on lines 44 to 71
SegmentNotAllocated = 107; // segment不存在
FileNotExists = 102; // 文件不存在
OtherError = -3; // 其他错误
}

enum CopysetStatusCode{
CopysetSuccess = 0;
Exist = 1; // copyset node 已经存在
NotExist = 2;
UnknowErr = 3;
Healthy = 4;
}

enum ChunkStatusCode{
ChunkSuccess = 0;
Redirect = 1; //不是leader,重定向
DiskErr = 2; //磁盘返回错误
CrcFail = 3; //Crc校验错误
InvalidReqParam = 4; //请求参数错误
NoEnoughSpace = 5; //空间不够
CopysetNotExist = 6; //copyset不存在
ChunkNotExist = 7; //chunk或其快照文件不存在
UnknowFailure = 8; //未知错误
OverLoad = 9; //服务端过载
Backward = 10; // 请求的版本落后当前chunk的版本
ChunkExist = 11; //chunk已存在
EpochOld = 12; // 请求中的epoch太老了
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English and alignment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English and alignment

fix

Comment on lines 28 to 30
kCpsHealthy = 0 // chunkserver上所有copyset健康
kNotHealthy = -1 // chunkserver上有copyset不健康
kNotOnline = -2 // chunkserver不在线
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

english

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

english

fix

Comment on lines 167 to 169
row["total copysets"] = total
row["unhealthy copysets"] = unCnt
row["unhealthy ratio"] = ratio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add in internal/utils/row.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add in internal/utils/row.go

fix

Comment on lines 21 to 31
// 解析结果失败
kParseError = -1
// peer数量小于预期
kPeersNoSufficient = -2
// 副本间的index差距太大
kLogIndexGapTooBig = -3
// 有副本在安装快照
kInstallingSnapshot = -4
// 少数副本不在线
kMinorityPeerNotOnline = -5
// 大多数副本不在线
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

english

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

english

fix

for _, cpsInfo := range copysetInfos {
cpsIds = append(cpsIds, cpsInfo.GetCopysetId())
}
// fmt.Println("cpsIds is", cpsIds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

fix

@jolly-sy
Copy link
Contributor Author

这条命令会根据情况产生多种不一样的结果,表头无法统一,所以无法使用表格统一打印

@Cyber-SiKu
Copy link
Contributor

这条命令会根据情况产生多种不一样的结果,表头无法统一,所以无法使用表格统一打印

The table header is not necessarily formulated in init, you can add the header when you are sure.

@jolly-sy
Copy link
Contributor Author

cicheck

Comment on lines 377 to 379



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines

fix

required sint32 statusCode = 1;
repeated PoolsetInfo poolsetInfos = 2;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines

fix

@@ -0,0 +1,51 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to tools-v2/pkg/config/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to tools-v2/pkg/config/

fix

@@ -23,3 +23,4 @@ curvebs:
root:
user: root
password: root_password

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines

CURVEBS_PASSWORD = "password"
VIPER_CURVEBS_PASSWORD = "curvebs.root.password"
CURVEBS_DEFAULT_PASSWORD = "root_password"
CURVEBS_CLUSTERMAP = "bsClusterMap"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase

all lowercase is ambiguous

VIPER_CURVEBS_PORT = "curvebs.port"
CURVEBS_CHUNKSERVER_ID = "csId"
VIPER_CURVEBS_CHUNKSERVER_ID = "curvebs.csId"
CURVEBS_CHUNKSERVER_ADDR = "csAddr"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

CURVEBS_CHUNKSERVER_ID = "csId"
VIPER_CURVEBS_CHUNKSERVER_ID = "curvebs.csId"
CURVEBS_CHUNKSERVER_ADDR = "csAddr"
VIPER_CURVEBS_CHUNKSERVER_ADDR = "curvebs.csAddr"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

all lowercase is ambiguous

VIPER_CURVEBS_CHUNK_SIZE = "curvebs.chunkSize"
CURVEBS_PORT = "port"
VIPER_CURVEBS_PORT = "curvebs.port"
CURVEBS_CHUNKSERVER_ID = "csId"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

all lowercase is ambiguous

@@ -47,7 +47,7 @@ func setupRootCommand(cmd *cobra.Command) {
}

func newCurveCommand() *cobra.Command {
cmd := &cobra.Command{
rootCmd := &cobra.Command{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename?

for test , I will change it back

@@ -166,7 +166,7 @@ func (tCmd *TopologyCommand) scanZones() *cmderror.CmdError {

func (tCmd *TopologyCommand) removeZones() *cmderror.CmdError {
tCmd.deleteZoneRpc = &DeleteZoneRpc{}
tCmd.deleteZoneRpc.Info = basecmd.NewRpc(tCmd.addrs, tCmd.timeout, tCmd.retryTimes, "DeleteServer")
tCmd.deleteZoneRpc.Info = basecmd.NewRpc(tCmd.addrs, tCmd.timeout, tCmd.retryTimes, "DeleteZone")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job!

@@ -189,26 +189,26 @@ func (eCmd *EtcdCommand) ResultPlainOutput() error {
}

func NewStatusEtcdCommand() *EtcdCommand {
etcdCmd := &EtcdCommand{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename?

coding error. fix

Comment on lines 103 to 104
// fmt.Println("user:", owner)
// fmt.Println("viper:", viper.GetString(config.VIPER_CURVEBS_USER))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete this

fix

func (ctCmd *ClusterTopoCmd) RunCommand(cmd *cobra.Command, args []string) error {
err := ctCmd.updateTopology()
if err.TypeCode() != cmderror.CODE_SUCCESS {
//return fmt.Errorf(err.Message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

fix

}

func (mdvCmd *MayDamVolCmd) ListChunkServersOnServers() *cmderror.CmdError {
// fmt.Println("ListChunkServersOnServers() in")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

fix

mdvCmd.isRetired = true
continue
}
//fmt.Println(chunkServer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

fix

}

func (mdvCmd *MayDamVolCmd) CheckIfChunkServerOnline(csAddr string) bool {
// fmt.Printf("CheckIfChunkServerOnline() in, csAddr is csAddr %s", csAddr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

fix

}

func (mdvCmd *MayDamVolCmd) FindOffLineChunkServers() *cmderror.CmdError {
// fmt.Println("FindOffLineChunkServers() in")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

fix

Comment on lines 92 to 116
// 列出集群中所有的server
err := mdvCmd.GetServersInfo()
if err.TypeCode() != cmderror.CODE_SUCCESS {
return err.ToError()
}
// 列出每台server上所有的chunkserver
err1 := mdvCmd.ListChunkServersOnServers()
if err1.TypeCode() != cmderror.CODE_SUCCESS {
return err1.ToError()
}
// 找出所有离线的chunkserver并记录这些chunkserver的地址到mdvCmd.offLineCsAddrs
err = mdvCmd.FindOffLineChunkServers()
if err.TypeCode() != cmderror.CODE_SUCCESS {
return err.ToError()
}
if len(mdvCmd.offLineCsAddrs) == 0 {
// fmt.Println("len(mdvCmd.offLineCsAddrs) == 0")
return err.ToError()
}
// 获取所有离线server上的copysets
err = mdvCmd.GetCopySetsOnOffLineCs()
if err.TypeCode() != cmderror.CODE_SUCCESS {
return err.ToError()
}
//统计各个copysets出现的次数,2次及以上的视为损坏的copyset,记录进mdvCmd.damagedCps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English note

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English note

fix

Copy link
Contributor

@Cyber-SiKu Cyber-SiKu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete tools-v2/pkg/cli/command/curvebs/list/topo

func NewMayDamVolCmd() *cobra.Command {
mdvCmd := &MayDamVolCmd{
FinalCurveCmd: basecmd.FinalCurveCmd{
Use: "may-damaged-vols",
Copy link
Contributor

@Cyber-SiKu Cyber-SiKu Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damaged-vols may be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damaged-vols may be better?

no, original name is may-broken-vol, may can't be removed

@jolly-sy jolly-sy force-pushed the bsTool branch 2 times, most recently from c3ed48d to 902c0e7 Compare January 4, 2023 08:25
@aspirer
Copy link
Contributor

aspirer commented Feb 16, 2023

we should split these commands and commit them one by one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants