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:
yunion-ci-robot
2019-04-22 10:33:11 +08:00
committed by GitHub
3 changed files with 12 additions and 0 deletions
+5
View File
@@ -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()))
+5
View File
@@ -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)
}
+2
View File
@@ -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