mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
避免rebuild_root时因镜像状态变化导致上传镜像超过限制
This commit is contained in:
@@ -116,7 +116,7 @@ func (self *SHost) _createVM(name string, imgId string, sysDisk cloudprovider.SD
|
||||
log.Errorf("getiamge fail %s", err)
|
||||
return "", err
|
||||
}
|
||||
if img.ImageState != ImageStatusAvailable {
|
||||
if img.ImageState != ImageStatusNormal || img.ImageState != ImageStatusUsing {
|
||||
log.Errorf("image %s status %s", imgId, img.ImageState)
|
||||
return "", fmt.Errorf("image not ready")
|
||||
}
|
||||
|
||||
+11
-15
@@ -32,10 +32,12 @@ import (
|
||||
type ImageStatusType string
|
||||
|
||||
const (
|
||||
ImageStatusCreating ImageStatusType = "Creating"
|
||||
ImageStatusAvailable ImageStatusType = "NORMAL"
|
||||
ImageStatusUnAvailable ImageStatusType = "UnAvailable"
|
||||
ImageStatusCreateFailed ImageStatusType = "CreateFailed"
|
||||
ImageStatusCreating ImageStatusType = "CREATING"
|
||||
ImageStatusNormal ImageStatusType = "NORMAL"
|
||||
ImageStatusSycing ImageStatusType = "SYNCING"
|
||||
ImageStatusImporting ImageStatusType = "IMPORTING"
|
||||
ImageStatusUsing ImageStatusType = "USING"
|
||||
ImageStatusDeleting ImageStatusType = "DELETING"
|
||||
)
|
||||
|
||||
type SImage struct {
|
||||
@@ -133,14 +135,10 @@ func (self *SImage) Delete(ctx context.Context) error {
|
||||
|
||||
func (self *SImage) GetStatus() string {
|
||||
switch self.ImageState {
|
||||
case ImageStatusCreating:
|
||||
case ImageStatusCreating, ImageStatusSycing, ImageStatusImporting:
|
||||
return models.CACHED_IMAGE_STATUS_CACHING
|
||||
case ImageStatusAvailable:
|
||||
case ImageStatusNormal, ImageStatusUsing:
|
||||
return models.CACHED_IMAGE_STATUS_READY
|
||||
case ImageStatusUnAvailable:
|
||||
return models.CACHED_IMAGE_STATUS_CACHE_FAILED
|
||||
case ImageStatusCreateFailed:
|
||||
return models.CACHED_IMAGE_STATUS_CACHE_FAILED
|
||||
default:
|
||||
return models.CACHED_IMAGE_STATUS_CACHE_FAILED
|
||||
}
|
||||
@@ -148,14 +146,12 @@ func (self *SImage) GetStatus() string {
|
||||
|
||||
func (self *SImage) GetImageStatus() string {
|
||||
switch self.ImageState {
|
||||
case ImageStatusCreating:
|
||||
case ImageStatusCreating, ImageStatusSycing, ImageStatusImporting:
|
||||
return cloudprovider.IMAGE_STATUS_SAVING
|
||||
case ImageStatusAvailable:
|
||||
case ImageStatusNormal, ImageStatusUsing:
|
||||
return cloudprovider.IMAGE_STATUS_ACTIVE
|
||||
case ImageStatusUnAvailable:
|
||||
case ImageStatusDeleting:
|
||||
return cloudprovider.IMAGE_STATUS_DELETED
|
||||
case ImageStatusCreateFailed:
|
||||
return cloudprovider.IMAGE_STATUS_KILLED
|
||||
default:
|
||||
return cloudprovider.IMAGE_STATUS_DELETED
|
||||
}
|
||||
|
||||
@@ -150,9 +150,10 @@ func (self *SStoragecache) UploadImage(ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
log.Errorf("GetImageStatus error %s", err)
|
||||
}
|
||||
if status == ImageStatusAvailable && !isForce {
|
||||
if (status == ImageStatusNormal || status == ImageStatusUsing) && !isForce {
|
||||
return extId, nil
|
||||
}
|
||||
log.Debugf("image status: %s isForce: %v", status, isForce)
|
||||
} else {
|
||||
log.Debugf("UploadImage: no external ID")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user