mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: save guest image with empty partition fail (#14189)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -24,6 +24,8 @@ import (
|
||||
|
||||
type GuestImageDetails struct {
|
||||
apis.SharableVirtualResourceDetails
|
||||
apis.EncryptedResourceDetails
|
||||
|
||||
SGuestImage
|
||||
|
||||
//Status string `json:"status"`
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package diskutils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -149,7 +148,7 @@ func (d *SKVMGuestDisk) mountKvmRootfs(readonly bool) (fsdriver.IRootFsDriver, e
|
||||
}
|
||||
}
|
||||
if len(partitions) == 0 {
|
||||
return nil, fmt.Errorf("not found any partitions")
|
||||
return nil, errors.Wrap(errors.ErrNotFound, "not found any partitions")
|
||||
}
|
||||
return nil, errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
@@ -233,8 +233,11 @@ func (*DeployerServer) SaveToGlance(ctx context.Context, req *deployapi.SaveToGl
|
||||
if req.Compress {
|
||||
kvmDisk.Zerofree()
|
||||
}
|
||||
} else if errors.Cause(err) == errors.ErrNotFound {
|
||||
// ignore no partition error
|
||||
err = nil
|
||||
} else {
|
||||
log.Errorf("")
|
||||
log.Errorf("SaveToGlance: MountKvmRootfs fail: %s", err)
|
||||
}
|
||||
return err
|
||||
}()
|
||||
|
||||
@@ -388,6 +388,7 @@ func (s *SLocalStorage) SaveToGlance(ctx context.Context, params interface{}) (j
|
||||
|
||||
func (s *SLocalStorage) saveToGlance(ctx context.Context, imageId, imagePath string,
|
||||
compress bool, format string, encryptKey string, encFormat qemuimg.TEncryptFormat, encAlg seclib2.TSymEncAlg) error {
|
||||
log.Infof("saveToGlance %s", imagePath)
|
||||
diskInfo := &deployapi.DiskInfo{
|
||||
Path: imagePath,
|
||||
}
|
||||
@@ -396,9 +397,10 @@ func (s *SLocalStorage) saveToGlance(ctx context.Context, imageId, imagePath str
|
||||
diskInfo.EncryptFormat = string(encFormat)
|
||||
diskInfo.EncryptAlg = string(encAlg)
|
||||
}
|
||||
ret, err := deployclient.GetDeployClient().SaveToGlance(context.Background(),
|
||||
ret, err := deployclient.GetDeployClient().SaveToGlance(ctx,
|
||||
&deployapi.SaveToGlanceParams{DiskInfo: diskInfo, Compress: compress})
|
||||
if err != nil {
|
||||
log.Errorf("GetDeployClient.SaveToGlance fail %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -362,10 +362,12 @@ func (manager *SGuestImageManager) FetchCustomizeColumns(
|
||||
rows := make([]api.GuestImageDetails, len(objs))
|
||||
|
||||
virtRows := manager.SSharableVirtualResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
encRows := manager.SEncryptedResourceManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
for i := range rows {
|
||||
rows[i] = api.GuestImageDetails{
|
||||
SharableVirtualResourceDetails: virtRows[i],
|
||||
EncryptedResourceDetails: encRows[i],
|
||||
}
|
||||
guestImage := objs[i].(*SGuestImage)
|
||||
rows[i] = guestImage.getMoreDetails(ctx, userCred, query, rows[i])
|
||||
|
||||
@@ -2023,7 +2023,7 @@ func (img *SImage) Pipeline(ctx context.Context, userCred mcclient.TokenCredenti
|
||||
if img.Status != api.IMAGE_STATUS_ACTIVE {
|
||||
img.SetStatus(userCred, api.IMAGE_STATUS_ACTIVE, "image pipeline complete")
|
||||
}
|
||||
if updated {
|
||||
if updated && img.IsGuestImage.IsFalse() {
|
||||
kwargs := jsonutils.NewDict()
|
||||
kwargs.Set("name", jsonutils.NewString(img.GetName()))
|
||||
osType, err := ImagePropertyManager.GetProperty(img.Id, api.IMAGE_OS_TYPE)
|
||||
|
||||
Reference in New Issue
Block a user