From 2fa1606e7c0f1d81b0e539ea26346596dad5a2c6 Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Sun, 22 Mar 2026 23:59:39 +0800 Subject: [PATCH] fix(region): check instance snapshot joint is nil on snapshot purge (#24515) --- pkg/compute/models/instance_snapshots.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/compute/models/instance_snapshots.go b/pkg/compute/models/instance_snapshots.go index 8d27a2aba6..db1c32cd01 100644 --- a/pkg/compute/models/instance_snapshots.go +++ b/pkg/compute/models/instance_snapshots.go @@ -635,10 +635,16 @@ func (self *SInstanceSnapshot) PerformPurge(ctx context.Context, userCred mcclie isjp := new(SInstanceSnapshotJoint) err = InstanceSnapshotJointManager.Query(). Equals("instance_snapshot_id", self.Id).Equals("snapshot_id", snapshotId).First(isjp) - err = isjp.Delete(ctx, userCred) - if err != nil { - return nil, errors.Wrapf(err, "delete instance snapshot joint: %s", snapshotId) + if err == nil || isjp != nil { + isjp.SetModelManager(InstanceSnapshotJointManager, isjp) + err = isjp.Delete(ctx, userCred) + if err != nil { + return nil, errors.Wrapf(err, "delete instance snapshot joint: %s", snapshotId) + } + } else { + log.Errorf("failed get instance_snapshot %s join %s: %s", self.Id, snapshotId, err) } + _, err = snapshots[i].PerformPurge(ctx, userCred, query, data) if err != nil { return nil, errors.Wrapf(err, "delete snapshot: %s", snapshotId)