fix: 避免同步删除失败

This commit is contained in:
Qu Xuan
2020-06-18 14:25:36 +08:00
parent f4b7044767
commit 3c75119c50
2 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -1329,9 +1329,12 @@ func (self *SDBInstance) syncRemoveCloudDBInstance(ctx context.Context, userCred
lockman.LockObject(ctx, self)
defer lockman.ReleaseObject(ctx, self)
self.SetDisableDelete(userCred, false)
err := self.ValidateDeleteCondition(ctx)
if err != nil { // cannot delete
return self.SetStatus(userCred, api.VPC_STATUS_UNKNOWN, "sync to delete")
self.SetStatus(userCred, api.VPC_STATUS_UNKNOWN, "sync to delete")
return errors.Wrap(err, "ValidateDeleteCondition")
}
return self.RealDelete(ctx, userCred)
}
+4 -1
View File
@@ -500,9 +500,12 @@ func (self *SElasticcache) syncRemoveCloudElasticcache(ctx context.Context, user
lockman.LockObject(ctx, self)
defer lockman.ReleaseObject(ctx, self)
self.SetDisableDelete(userCred, false)
err := self.ValidateDeleteCondition(ctx)
if err != nil {
return self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_ERROR, "sync to delete")
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_ERROR, "sync to delete")
return errors.Wrap(err, "ValidateDeleteCondition")
}
return self.SVirtualResourceBase.Delete(ctx, userCred)
}