fix(region): allow batch resize disk (#24049)

This commit is contained in:
屈轩
2026-01-09 14:04:45 +08:00
committed by GitHub
parent 209e5445f6
commit 84738bc136
12 changed files with 12 additions and 12 deletions

View File

@@ -112,7 +112,7 @@ func (self *SAliyunGuestDriver) GetDeployStatus() ([]string, error) {
}
func (self *SAliyunGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
return nil

View File

@@ -210,7 +210,7 @@ func (self *SAwsGuestDriver) ValidateCreateData(ctx context.Context, userCred mc
func (self *SAwsGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
// https://docs.amazonaws.cn/AWSEC2/latest/UserGuide/stop-start.html
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if disk.DiskType == api.DISK_TYPE_SYS && !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_IO1_SSD, api.STORAGE_IO2_SSD, api.STORAGE_STANDARD_HDD, api.STORAGE_GP2_SSD, api.STORAGE_GP3_SSD}) {

View File

@@ -117,7 +117,7 @@ func (self *SAzureGuestDriver) IsNeedRestartForResetLoginInfo() bool {
func (self *SAzureGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
//https://docs.microsoft.com/en-us/rest/api/compute/disks/update
//Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
return nil

View File

@@ -158,7 +158,7 @@ func (self *SBaiduGuestDriver) IsSupportSetAutoRenew() bool {
}
func (self *SBaiduGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("cannot resize disk when guest in status %s", guest.Status)
}
return nil

View File

@@ -107,7 +107,7 @@ func (self *SCtyunGuestDriver) GetGuestInitialStateAfterRebuild() string {
}
func (self *SCtyunGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_CTYUN_SATA, api.STORAGE_CTYUN_SAS, api.STORAGE_CTYUN_SSD}) {

View File

@@ -301,7 +301,7 @@ func (self *SESXiGuestDriver) ValidateCreateEip(ctx context.Context, userCred mc
}
func (self *SESXiGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
count, err := guest.GetInstanceSnapshotCount()

View File

@@ -154,7 +154,7 @@ func (self *SGoogleGuestDriver) GetDeployStatus() ([]string, error) {
}
func (self *SGoogleGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if !utils.IsInStringArray(storage.StorageType, []string{

View File

@@ -98,7 +98,7 @@ func (self *SHuaweiGuestDriver) GetDeployStatus() ([]string, error) {
}
func (self *SHuaweiGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_HUAWEI_SATA, api.STORAGE_HUAWEI_SAS, api.STORAGE_HUAWEI_SSD}) {

View File

@@ -97,7 +97,7 @@ func (self *SKsyunGuestDriver) GetGuestInitialStateAfterRebuild() string {
}
func (self *SKsyunGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
return nil

View File

@@ -107,7 +107,7 @@ func (self *SQcloudGuestDriver) GetDeployStatus() ([]string, error) {
func (self *SQcloudGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
//https://cloud.tencent.com/document/product/362/5747
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if disk.DiskType == api.DISK_TYPE_SYS {

View File

@@ -90,7 +90,7 @@ func (self *SUCloudGuestDriver) GetGuestInitialStateAfterRebuild() string {
}
func (self *SUCloudGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
}
if !utils.IsInStringArray(storage.StorageType, []string{api.STORAGE_UCLOUD_CLOUD_SSD, api.STORAGE_UCLOUD_CLOUD_NORMAL}) {

View File

@@ -146,7 +146,7 @@ func (self *SVolcengineGuestDriver) IsSupportSetAutoRenew() bool {
}
func (self *SVolcengineGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY}) {
if !utils.IsInStringArray(guest.Status, []string{api.VM_RUNNING, api.VM_READY, api.VM_START_RESIZE_DISK, api.VM_RESIZE_DISK}) {
return fmt.Errorf("cannot resize disk when guest in status %s", guest.Status)
}
return nil