mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #9769 from ioito/automated-cherry-pick-of-#9768-upstream-release-3.7
Automated cherry pick of #9768: fix(region): sync cachedimage info
This commit is contained in:
@@ -90,3 +90,18 @@ func (self *SCloudimage) syncRemove(ctx context.Context, userCred mcclient.Token
|
||||
|
||||
return self.Delete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (self *SCloudimage) syncWithImage(ctx context.Context, userCred mcclient.TokenCredential, image SCachedimage) error {
|
||||
_cachedImage, err := db.FetchByExternalId(CachedimageManager, image.GetGlobalId())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "db.FetchByExternalId(%s)", image.GetGlobalId())
|
||||
}
|
||||
cachedImage := _cachedImage.(*SCachedimage)
|
||||
_, err = db.Update(cachedImage, func() error {
|
||||
cachedImage.Info = image.Info
|
||||
cachedImage.Size = image.Size
|
||||
cachedImage.UEFI = image.UEFI
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1038,7 +1038,6 @@ func (self *SCloudregion) SyncCloudImages(ctx context.Context, userCred mcclient
|
||||
}
|
||||
|
||||
result := compare.SyncResult{}
|
||||
result.UpdateCnt = len(commondb)
|
||||
|
||||
for i := 0; i < len(removed); i++ {
|
||||
err := removed[i].syncRemove(ctx, userCred)
|
||||
@@ -1049,6 +1048,15 @@ func (self *SCloudregion) SyncCloudImages(ctx context.Context, userCred mcclient
|
||||
result.Delete()
|
||||
}
|
||||
|
||||
for i := 0; i < len(commonext); i++ {
|
||||
err := commondb[i].syncWithImage(ctx, userCred, commonext[i])
|
||||
if err != nil {
|
||||
result.UpdateError(errors.Wrapf(err, "updateCachedImage"))
|
||||
continue
|
||||
}
|
||||
result.Update()
|
||||
}
|
||||
|
||||
for i := 0; i < len(added); i++ {
|
||||
err = self.newCloudimage(ctx, userCred, added[i])
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user