Merge pull request #9123 from ioito/hotfix/qx-bucket-delete-condition

fix(region): allow delete resource which status is unknown
This commit is contained in:
Zexi Li
2020-12-01 21:04:52 +08:00
committed by GitHub
2 changed files with 10 additions and 3 deletions
+3
View File
@@ -1181,6 +1181,9 @@ func (bucket *SBucket) ValidatePurgeCondition(ctx context.Context) error {
}
func (bucket *SBucket) ValidateDeleteCondition(ctx context.Context) error {
if bucket.Status == api.BUCKET_STATUS_UNKNOWN {
return bucket.SSharableVirtualResourceBase.ValidateDeleteCondition(ctx)
}
if bucket.ObjectCnt > 0 {
return httperrors.NewNotEmptyError("not an empty bucket")
}
+7 -3
View File
@@ -209,6 +209,13 @@ func (self *SVpc) ValidateUpdateData(ctx context.Context, userCred mcclient.Toke
}
func (self *SVpc) ValidateDeleteCondition(ctx context.Context) error {
if self.Id == api.DEFAULT_VPC_ID {
return httperrors.NewProtectedResourceError("not allow to delete default vpc")
}
if self.Status == api.VPC_STATUS_UNKNOWN {
return self.SEnabledStatusInfrasResourceBase.ValidateDeleteCondition(ctx)
}
cnt, err := self.GetNetworkCount()
if err != nil {
return httperrors.NewInternalServerError("GetNetworkCount fail %s", err)
@@ -223,9 +230,6 @@ func (self *SVpc) ValidateDeleteCondition(ctx context.Context) error {
if cnt > 0 {
return httperrors.NewNotEmptyError("VPC not empty, please delete nat gateway first")
}
if self.Id == api.DEFAULT_VPC_ID {
return httperrors.NewProtectedResourceError("not allow to delete default vpc")
}
cnt, err = self.GetVpcPeeringConnectionCount()
if err != nil {
return httperrors.NewInternalServerError("GetRequesterVpcPeeringConnections fail %v", err)