diff --git a/pkg/compute/models/buckets.go b/pkg/compute/models/buckets.go index 400a5d5d0e..1b3ae621f6 100644 --- a/pkg/compute/models/buckets.go +++ b/pkg/compute/models/buckets.go @@ -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") } diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index 9a7d43d2a1..7caaab02a9 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -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)