mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #4616 from swordqiu/hotfix/qj-huawei-uncache-image-not-found
fix: huawei uncache image fail
This commit is contained in:
@@ -137,17 +137,17 @@ func (self *SManagedVirtualizationHostDriver) RequestUncacheImage(ctx context.Co
|
||||
|
||||
iImage, err := iStorageCache.GetIImageById(scimg.ExternalId)
|
||||
if err != nil {
|
||||
if err == cloudprovider.ErrNotFound {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
log.Errorf("GetIImageById fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "iStorageCache.GetIImageById")
|
||||
}
|
||||
|
||||
err = iImage.Delete(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("iImage Delete fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "iImage.Delete")
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
@@ -218,10 +219,13 @@ func (self *SImage) GetIStoragecache() cloudprovider.ICloudStoragecache {
|
||||
return self.storageCache
|
||||
}
|
||||
|
||||
func (self *SRegion) GetImage(imageId string) (SImage, error) {
|
||||
image := SImage{}
|
||||
err := DoGet(self.ecsClient.Images.Get, imageId, nil, &image)
|
||||
return image, err
|
||||
func (self *SRegion) GetImage(imageId string) (*SImage, error) {
|
||||
image := &SImage{}
|
||||
err := DoGet(self.ecsClient.Images.Get, imageId, nil, image)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "DoGet")
|
||||
}
|
||||
return image, nil
|
||||
}
|
||||
|
||||
func excludeImage(image SImage) bool {
|
||||
|
||||
@@ -107,8 +107,11 @@ func (self *SStoragecache) GetIImages() ([]cloudprovider.ICloudImage, error) {
|
||||
|
||||
func (self *SStoragecache) GetIImageById(extId string) (cloudprovider.ICloudImage, error) {
|
||||
image, err := self.region.GetImage(extId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "self.region.GetImage")
|
||||
}
|
||||
image.storageCache = self
|
||||
return &image, err
|
||||
return image, nil
|
||||
}
|
||||
|
||||
func (self *SStoragecache) GetPath() string {
|
||||
@@ -126,7 +129,7 @@ func (self *SStoragecache) CreateIImage(snapshotId, imageName, osType, imageDesc
|
||||
} else {
|
||||
image.storageCache = self
|
||||
iimage := make([]cloudprovider.ICloudImage, 1)
|
||||
iimage[0] = &image
|
||||
iimage[0] = image
|
||||
if err := cloudprovider.WaitStatus(iimage[0], "avaliable", 15*time.Second, 3600*time.Second); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user