Skip to content

Commit

Permalink
fix(region): skip set lost name when purge deleted vm (#19752)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Mar 20, 2024
1 parent 6cac127 commit c73ac42
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/compute/models/guests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2974,13 +2974,6 @@ func (self *SGuest) SyncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
}
}

if !lostNamePattern.MatchString(self.Name) {
db.Update(self, func() error {
self.Name = fmt.Sprintf("%s-lost@%s", self.Name, timeutils.ShortDate(time.Now()))
return nil
})
}

if self.Status != api.VM_UNKNOWN {
self.SetStatus(ctx, userCred, api.VM_UNKNOWN, "Sync lost")
}
Expand All @@ -2995,6 +2988,15 @@ func (self *SGuest) SyncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
Obj: self,
Action: notifyclient.ActionSyncDelete,
})

return nil
}

if !lostNamePattern.MatchString(self.Name) {
db.Update(self, func() error {
self.Name = fmt.Sprintf("%s-lost@%s", self.Name, timeutils.ShortDate(time.Now()))
return nil
})
}

return nil
Expand Down

0 comments on commit c73ac42

Please sign in to comment.