mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
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:
@@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user