Skip to content

Commit 2fa1606

Browse files
authored
fix(region): check instance snapshot joint is nil on snapshot purge (#24515)
1 parent 1ec3a23 commit 2fa1606

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/compute/models/instance_snapshots.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,16 @@ func (self *SInstanceSnapshot) PerformPurge(ctx context.Context, userCred mcclie
635635
isjp := new(SInstanceSnapshotJoint)
636636
err = InstanceSnapshotJointManager.Query().
637637
Equals("instance_snapshot_id", self.Id).Equals("snapshot_id", snapshotId).First(isjp)
638-
err = isjp.Delete(ctx, userCred)
639-
if err != nil {
640-
return nil, errors.Wrapf(err, "delete instance snapshot joint: %s", snapshotId)
638+
if err == nil || isjp != nil {
639+
isjp.SetModelManager(InstanceSnapshotJointManager, isjp)
640+
err = isjp.Delete(ctx, userCred)
641+
if err != nil {
642+
return nil, errors.Wrapf(err, "delete instance snapshot joint: %s", snapshotId)
643+
}
644+
} else {
645+
log.Errorf("failed get instance_snapshot %s join %s: %s", self.Id, snapshotId, err)
641646
}
647+
642648
_, err = snapshots[i].PerformPurge(ctx, userCred, query, data)
643649
if err != nil {
644650
return nil, errors.Wrapf(err, "delete snapshot: %s", snapshotId)

0 commit comments

Comments
 (0)