Merge pull request #7438 from swordqiu/hotfix/qj-vpc-wire-share-status-sync

fix: sync share mode between vpc and wire
This commit is contained in:
Zexi Li
2020-08-01 10:37:54 +08:00
committed by GitHub
3 changed files with 23 additions and 13 deletions
+11 -9
View File
@@ -1176,15 +1176,17 @@ func syncOnPremiseCloudProviderInfo(
}
}
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
if cloudprovider.IsSupportCompute(driver) {
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
}
}
return nil
+1
View File
@@ -599,6 +599,7 @@ func (cache *SStoragecache) SyncCloudImages(
syncResult := compare.SyncResult{}
log.Debugln("localCachedImages started")
localCachedImages := cache.getCachedImages()
log.Debugf("localCachedImages %d", len(localCachedImages))
+11 -4
View File
@@ -309,7 +309,7 @@ func (manager *SWireManager) SyncWires(ctx context.Context, userCred mcclient.To
}
}
for i := 0; i < len(commondb); i += 1 {
err = commondb[i].syncWithCloudWire(ctx, userCred, commonext[i], provider)
err = commondb[i].syncWithCloudWire(ctx, userCred, commonext[i], vpc, provider)
if err != nil {
syncResult.UpdateError(err)
} else {
@@ -353,13 +353,19 @@ func (self *SWire) syncRemoveCloudWire(ctx context.Context, userCred mcclient.To
return err
}
func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.TokenCredential, extWire cloudprovider.ICloudWire, provider *SCloudprovider) error {
func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.TokenCredential, extWire cloudprovider.ICloudWire, vpc *SVpc, provider *SCloudprovider) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
// self.Name = extWire.GetName()
self.Bandwidth = extWire.GetBandwidth() // 10G
self.IsEmulated = extWire.IsEmulated()
if self.IsEmulated {
self.DomainId = vpc.DomainId
self.IsPublic = vpc.IsPublic
self.PublicScope = vpc.PublicScope
}
return nil
})
if err != nil {
@@ -408,6 +414,7 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
}
wire.IsEmulated = extWire.IsEmulated()
wire.DomainId = vpc.DomainId
wire.IsPublic = vpc.IsPublic
wire.PublicScope = vpc.PublicScope
@@ -418,10 +425,10 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
return nil, err
}
/*if provider != nil {
if provider != nil && !wire.IsEmulated {
SyncCloudDomain(userCred, &wire, provider.GetOwnerId())
wire.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
}*/
}
db.OpsLog.LogEvent(&wire, db.ACT_CREATE, wire.GetShortDesc(ctx), userCred)
return &wire, nil