fix(region): enable create cloudpods vm with iso image (#20731)

This commit is contained in:
屈轩
2024-07-08 21:31:42 +08:00
committed by GitHub
parent 669544c5c5
commit d5432e8e5a
4 changed files with 11 additions and 7 deletions
-1
View File
@@ -54,7 +54,6 @@ func FetchJointByIds(manager IJointModelManager, masterId, slaveId string, query
}
cond := sqlchemy.AND(sqlchemy.Equals(masterField, masterId), sqlchemy.Equals(slaveField, slaveId))
q = q.Filter(cond)
q.DebugQuery()
q = manager.FilterByParams(q, query)
count, err := q.CountWithError()
if err != nil {
@@ -129,6 +129,11 @@ func (drv *SManagedVirtualizedGuestDriver) GetJsonDescAtHost(ctx context.Context
cache := storage.GetStoragecache()
imageId := disk.GetTemplateId()
//避免因同步过来的instance没有对应的imagecache信息,重置密码时引发空指针访问
if len(imageId) == 0 {
if cdrom := guest.GetCdrom(); cdrom != nil {
imageId = cdrom.ImageId
}
}
if scimg := models.StoragecachedimageManager.GetStoragecachedimage(cache.Id, imageId); scimg != nil {
config.ExternalImageId = scimg.ExternalId
img := scimg.GetCachedimage()
+3 -3
View File
@@ -138,6 +138,9 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context.
log.Debugf("UploadImage: no external ID")
return iStorageCache.UploadImage(ctx, image, callback)
}()
if err != nil {
return nil, err
}
log.Infof("upload image %s id: %s", image.ImageName, image.ExternalId)
} else {
_, err := iStorageCache.GetIImageById(cachedImage.ExternalId)
@@ -147,9 +150,6 @@ func (self *SManagedVirtualizationHostDriver) CheckAndSetCacheImage(ctx context.
image.ExternalId = cachedImage.ExternalId
size = cachedImage.Size
}
if err != nil {
return nil, err
}
// should record the externalId immediately
// so the waiting goroutine could pick the new externalId
+3 -3
View File
@@ -21,8 +21,8 @@ import (
"yunion.io/x/cloudmux/pkg/cloudprovider"
"yunion.io/x/cloudmux/pkg/multicloud"
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/imagetools"
"yunion.io/x/pkg/util/qemuimgfmt"
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/image"
@@ -188,9 +188,9 @@ func (self *SRegion) GetImage(id string) (*SImage, error) {
}
func (self *SRegion) UploadImage(ctx context.Context, opts *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) {
reader, sizeByte, err := opts.GetReader(opts.ImageId, string(qemuimgfmt.QCOW2))
reader, sizeByte, err := opts.GetReader(opts.ImageId, "")
if err != nil {
return "", err
return "", errors.Wrapf(err, "GetReader")
}
params := map[string]interface{}{