Merge pull request #10925 from ioito/hotfix/qx-multi-region-sync

fix(region): sync multi region resource at same time
This commit is contained in:
Zexi Li
2021-08-06 15:09:36 +08:00
committed by GitHub
2 changed files with 2 additions and 8 deletions
+1 -4
View File
@@ -457,7 +457,7 @@ func (self *SCloudproviderregion) getSyncTaskKey() string {
}
}
func (self *SCloudproviderregion) submitSyncTask(ctx context.Context, userCred mcclient.TokenCredential, syncRange SSyncRange, waitChan chan bool) {
func (self *SCloudproviderregion) submitSyncTask(ctx context.Context, userCred mcclient.TokenCredential, syncRange SSyncRange) {
self.markStartSync(userCred)
RunSyncCloudproviderRegionTask(ctx, self.getSyncTaskKey(), func() {
nopanic.Run(func() {
@@ -467,9 +467,6 @@ func (self *SCloudproviderregion) submitSyncTask(ctx context.Context, userCred m
log.Errorf("DoSync faild %v", err)
}
})
if waitChan != nil {
waitChan <- true
}
})
}
+1 -4
View File
@@ -1413,14 +1413,11 @@ func (provider *SCloudprovider) syncCloudproviderRegions(ctx context.Context, us
for i := range cprs {
if cprs[i].Enabled && cprs[i].CanSync() && (!autoSync || cprs[i].needAutoSync()) && (len(regionIds) == 0 || utils.IsInStringArray(cprs[i].CloudregionId, regionIds)) {
syncCnt += 1
var waitChan chan bool = nil
if wg != nil {
wg.Add(1)
waitChan = make(chan bool)
}
cprs[i].submitSyncTask(ctx, userCred, syncRange, waitChan)
cprs[i].submitSyncTask(ctx, userCred, syncRange)
if wg != nil {
<-waitChan
wg.Done()
}
}