mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
refactor(master): use IsDeleted for volume status checks.
close:#1000542120
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
(cherry picked from commit 0ad5c80c05)
This commit is contained in:
parent
57321ed6b5
commit
d8638e22b5
@ -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
|
||||
}
|
||||
|
||||
@ -671,7 +671,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