mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #526 from swordqiu/hotfix/qj-auto-purge-removed-servers
fix: automatically purge removed servers on public cloud
This commit is contained in:
@@ -1839,6 +1839,11 @@ func (self *SGuest) syncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
|
||||
return nil
|
||||
}
|
||||
|
||||
if options.SyncPurgeRemovedResources.Contains(self.Keyword()) {
|
||||
log.Debugf("purge removed resource %s", self.Name)
|
||||
return self.purge(ctx, userCred)
|
||||
}
|
||||
|
||||
if !lostNamePattern.MatchString(self.Name) {
|
||||
db.Update(self, func() error {
|
||||
self.Name = fmt.Sprintf("%s-lost@%s", self.Name, timeutils.ShortDate(time.Now()))
|
||||
|
||||
@@ -8,9 +8,14 @@ import (
|
||||
|
||||
var (
|
||||
NameSyncResources stringutils2.SSortedStrings
|
||||
|
||||
SyncPurgeRemovedResources stringutils2.SSortedStrings
|
||||
)
|
||||
|
||||
func InitNameSyncResources() {
|
||||
NameSyncResources = stringutils2.NewSortedStrings(Options.NameSyncResources)
|
||||
log.Infof("NameSyncResources: %s", NameSyncResources)
|
||||
|
||||
SyncPurgeRemovedResources = stringutils2.NewSortedStrings(Options.SyncPurgeRemovedResources)
|
||||
log.Infof("SyncPurgeRemovedResources: %s", SyncPurgeRemovedResources)
|
||||
}
|
||||
|
||||
@@ -101,6 +101,8 @@ type ComputeOptions struct {
|
||||
|
||||
NameSyncResources []string `help:"resources that need synchronization of name"`
|
||||
|
||||
SyncPurgeRemovedResources []string `help:"resources that shoud be purged immediately if found removed"`
|
||||
|
||||
DisconnectedCloudAccountRetryProbeIntervalHours int `help:"interval to wait to probe status of a disconnected cloud account" default:"24"`
|
||||
|
||||
SCapabilityOptions
|
||||
|
||||
Reference in New Issue
Block a user