diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index dbb15fee10..b69bbbf441 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -106,8 +106,10 @@ const ( ) var ( - DISK_TYPES = []string{DISK_TYPE_ROTATE, DISK_TYPE_SSD, DISK_TYPE_HYBRID} - STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_UCLOUD_LOCAL_NORMAL, STORAGE_UCLOUD_LOCAL_SSD, STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK} + DISK_TYPES = []string{DISK_TYPE_ROTATE, DISK_TYPE_SSD, DISK_TYPE_HYBRID} + STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_UCLOUD_LOCAL_NORMAL, STORAGE_UCLOUD_LOCAL_SSD, STORAGE_UCLOUD_EXCLUSIVE_LOCAL_DISK, + STORAGE_EPHEMERAL_SSD, STORAGE_LOCAL_BASIC, STORAGE_LOCAL_SSD, STORAGE_LOCAL_PRO, STORAGE_OPENSTACK_NOVA, + STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_GOOGLE_LOCAL_SSD} STORAGE_SUPPORT_TYPES = STORAGE_LOCAL_TYPES STORAGE_ALL_TYPES = []string{ STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_SHEEPDOG, diff --git a/pkg/compute/guestdrivers/managedvirtual.go b/pkg/compute/guestdrivers/managedvirtual.go index 6b1180fa4b..e255324e1b 100644 --- a/pkg/compute/guestdrivers/managedvirtual.go +++ b/pkg/compute/guestdrivers/managedvirtual.go @@ -669,7 +669,9 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte } for _, guestdisk := range guest.GetDisks() { - if disk := guestdisk.GetDisk(); disk != nil && disk.AutoDelete { + disk := guestdisk.GetDisk() + storage := disk.GetStorage() + if disk != nil && disk.AutoDelete && !utils.IsInStringArray(storage.StorageType, api.STORAGE_LOCAL_TYPES) { idisk, err := disk.GetIDisk() if err != nil { if errors.Cause(err) == cloudprovider.ErrNotFound { @@ -678,6 +680,9 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte log.Errorf("disk.GetIDisk fail %s", err) return nil, err } + if idisk.GetStatus() == api.DISK_DEALLOC { + continue + } err = idisk.Delete(ctx) if err != nil { log.Errorf("idisk.Delete fail %s", err) diff --git a/pkg/multicloud/openstack/instance.go b/pkg/multicloud/openstack/instance.go index 8ebb663202..e33a784dae 100644 --- a/pkg/multicloud/openstack/instance.go +++ b/pkg/multicloud/openstack/instance.go @@ -540,7 +540,11 @@ func (region *SRegion) DeployVM(instanceId string, name string, password string, } func (instance *SInstance) DeleteVM(ctx context.Context) error { - return instance.host.zone.region.DeleteVM(instance.Id) + err := instance.host.zone.region.DeleteVM(instance.Id) + if err != nil { + return errors.Wrapf(err, "instance.host.zone.region.DeleteVM(%s)", instance.Id) + } + return cloudprovider.WaitDeleted(instance, time.Second*5, time.Minute*10) } func (region *SRegion) ReplaceSystemDisk(instanceId string, imageId string, passwd string, publicKey string, sysDiskSizeGB int) error {