mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(master): optimize the calculation of datanode decommission progress
Signed-off-by: chihe <chihe@oppo.com>
This commit is contained in:
parent
0ffe25c31d
commit
d479a79f73
@ -7119,6 +7119,9 @@ func (m *Server) cancelDecommissionDisk(w http.ResponseWriter, r *http.Request)
|
||||
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: ret})
|
||||
return
|
||||
}
|
||||
// remove from decommissioned disk
|
||||
m.cluster.deleteAndSyncDecommissionedDisk(dataNode, diskPath)
|
||||
|
||||
rstMsg := fmt.Sprintf("cancel decommission disk[%s] successfully ", key)
|
||||
sendOkReply(w, r, newSuccessHTTPReply(rstMsg))
|
||||
}
|
||||
|
||||
@ -443,26 +443,25 @@ func (dataNode *DataNode) updateDecommissionStatus(c *Cluster, debug bool) (uint
|
||||
dataNode.SetDecommissionStatus(markDecommission)
|
||||
return markDecommission, float64(0)
|
||||
}
|
||||
if successDiskNum == totalDisk {
|
||||
dataNode.SetDecommissionStatus(DecommissionSuccess)
|
||||
return DecommissionSuccess, float64(1)
|
||||
if successDiskNum+failedDiskNum+cancelDiskNum == totalDisk {
|
||||
if successDiskNum == totalDisk {
|
||||
dataNode.SetDecommissionStatus(DecommissionSuccess)
|
||||
return DecommissionSuccess, float64(1)
|
||||
}
|
||||
if cancelDiskNum != 0 {
|
||||
dataNode.SetDecommissionStatus(DecommissionCancel)
|
||||
} else {
|
||||
dataNode.SetDecommissionStatus(DecommissionFail)
|
||||
}
|
||||
}
|
||||
|
||||
if failedDiskNum == totalDisk {
|
||||
dataNode.SetDecommissionStatus(DecommissionFail)
|
||||
return DecommissionFail, progress
|
||||
}
|
||||
|
||||
if cancelDiskNum != 0 {
|
||||
dataNode.SetDecommissionStatus(DecommissionCancel)
|
||||
}
|
||||
if debug {
|
||||
log.LogInfof("action[updateDecommissionStatus] dataNode[%v] progress[%v] DecommissionDiskNum[%v] "+
|
||||
"DecommissionDisks %v markDiskNum[%v] successDiskNum[%v] failedDiskNum[%v] cancelDiskNum[%v]",
|
||||
dataNode.Addr, progress, len(dataNode.DecommissionDiskList), dataNode.DecommissionDiskList, markDiskNum,
|
||||
dataNode.Addr, progress/float64(totalDisk), len(dataNode.DecommissionDiskList), dataNode.DecommissionDiskList, markDiskNum,
|
||||
successDiskNum, failedDiskNum, cancelDiskNum)
|
||||
}
|
||||
return dataNode.GetDecommissionStatus(), progress
|
||||
return dataNode.GetDecommissionStatus(), progress / float64(totalDisk)
|
||||
}
|
||||
|
||||
func (dataNode *DataNode) GetLatestDecommissionDataPartition(c *Cluster) (partitions []*DataPartition) {
|
||||
|
||||
@ -238,6 +238,8 @@ func (c *Cluster) deleteAndSyncDecommissionedDisk(dataNode *DataNode, diskPath s
|
||||
}
|
||||
if err = c.syncUpdateDataNode(dataNode); err != nil {
|
||||
dataNode.addDecommissionedDisk(diskPath)
|
||||
log.LogWarnf("action[deleteAndSyncDecommissionedDisk]submit raft failed: %v, delete disks[%v], dataNode[%v]",
|
||||
err, diskPath, dataNode.Addr)
|
||||
return
|
||||
}
|
||||
log.LogInfof("action[deleteAndSyncDecommissionedDisk] finish, remaining decommissioned disks[%v], dataNode[%v]", dataNode.getDecommissionedDisks(), dataNode.Addr)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user