mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
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:
parent
e3acdb7c1f
commit
0ad5c80c05
@ -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)
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user