mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #10026 from ioito/automated-cherry-pick-of-#10025-upstream-release-3.7
Automated cherry pick of #10025: fix(region): purge snapshot with not status check
This commit is contained in:
@@ -630,9 +630,9 @@ func (snapshot *SSnapshot) purge(ctx context.Context, userCred mcclient.TokenCre
|
||||
lockman.LockObject(ctx, snapshot)
|
||||
defer lockman.ReleaseObject(ctx, snapshot)
|
||||
|
||||
err := snapshot.ValidateDeleteCondition(ctx)
|
||||
err := snapshot.ValidatePurgeCondition(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "ValidatePurgeCondition for snapshot %s(%s)", snapshot.Name, snapshot.Id)
|
||||
}
|
||||
return snapshot.RealDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
@@ -621,6 +621,10 @@ func (self *SSnapshot) ValidateDeleteCondition(ctx context.Context) error {
|
||||
if self.Status == api.SNAPSHOT_DELETING {
|
||||
return httperrors.NewBadRequestError("Cannot delete snapshot in status %s", self.Status)
|
||||
}
|
||||
return self.ValidatePurgeCondition(ctx)
|
||||
}
|
||||
|
||||
func (self *SSnapshot) ValidatePurgeCondition(ctx context.Context) error {
|
||||
count, err := InstanceSnapshotJointManager.Query().Equals("snapshot_id", self.Id).CountWithError()
|
||||
if err != nil {
|
||||
return httperrors.NewInternalServerError("Fetch instance snapshot error %s", err)
|
||||
|
||||
Reference in New Issue
Block a user