refactor(master): replace volume status checks with IsDeleted method for clarity. #1000542120

Updated multiple files to utilize the new IsDeleted method for checking volume deletion status, improving code readability and maintainability. This change affects cluster_task.go, cluster.go, monitor_metrics.go, and vol.go.

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
Victor1319 2025-12-12 10:44:56 +08:00
parent e3acdb7c1f
commit 0ad5c80c05
4 changed files with 11 additions and 8 deletions

View File

@ -1553,17 +1553,16 @@ func (c *Cluster) checkReplicaOfDataPartitions(ignoreDiscardDp bool) (
vols := c.copyVols()
for _, vol := range vols {
if vol.IsDeleted() {
continue
}
dps := vol.dataPartitions
for _, dp := range dps.partitions {
if ignoreDiscardDp && dp.IsDiscard {
continue
}
if (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) ||
(vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && time.Until(vol.DeleteExecTime) <= 0) {
continue
}
if proto.IsHot(vol.VolType) {
if dp.lostLeader(c) {
noLeaderDPs = append(noLeaderDPs, dp)

View File

@ -297,7 +297,7 @@ func (c *Cluster) checkReplicaMetaPartitions() (
markDeleteVolNames := make(VolNameSet)
vols := c.copyVols()
for _, vol := range vols {
if vol.Status == proto.VolStatusMarkDelete {
if vol.IsDeleted() {
markDeleteVolNames[vol.Name] = struct{}{}
continue
}
@ -354,7 +354,7 @@ func (c *Cluster) checkReplicaMetaPartitionsV1() (diagnosis *proto.MetaPartition
markDeleteVolNames := make(VolNameSet)
vols := c.copyVols()
for _, vol := range vols {
if vol.Status == proto.VolStatusMarkDelete {
if vol.IsDeleted() {
markDeleteVolNames[vol.Name] = struct{}{}
continue
}

View File

@ -662,7 +662,7 @@ func (mm *monitorMetrics) setMpAndDpMetrics() {
vols := mm.cluster.copyVols()
for _, vol := range vols {
if (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) || (vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && vol.DeleteExecTime.Before(time.Now())) {
if vol.IsDeleted() {
continue
}

View File

@ -447,6 +447,10 @@ func (mpsLock *mpsLockManager) CheckExceptionLock(interval time.Duration, expire
}
}
func (vol *Vol) IsDeleted() bool {
return (vol.Status == proto.VolStatusMarkDelete && !vol.Forbidden) || (vol.Status == proto.VolStatusMarkDelete && vol.Forbidden && vol.DeleteExecTime.Before(time.Now()))
}
func (vol *Vol) CheckStrategy(c *Cluster) {
// make sure resume all the processing ver deleting tasks before checking
if !atomic.CompareAndSwapInt32(&vol.VersionMgr.checkStrategy, 0, 1) {