mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
optimized: server delete log and wait time
This commit is contained in:
@@ -651,8 +651,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
log.Errorf("host.GetIHost fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "host.GetIHost")
|
||||
}
|
||||
|
||||
// 创建失败时external id为空。此时直接返回即可。不需要再调用公有云api
|
||||
@@ -665,14 +664,11 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Errorf("ihost.GetIVMById fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "ihost.GetIVMById(%s)", guest.ExternalId)
|
||||
}
|
||||
err = ivm.DeleteVM(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("ivm.DeleteVM fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "ivm.DeleteVM")
|
||||
}
|
||||
|
||||
for _, guestdisk := range guest.GetDisks() {
|
||||
@@ -684,16 +680,14 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
continue
|
||||
}
|
||||
log.Errorf("disk.GetIDisk fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "disk.GetIDisk")
|
||||
}
|
||||
if idisk.GetStatus() == api.DISK_DEALLOC {
|
||||
continue
|
||||
}
|
||||
err = idisk.Delete(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("idisk.Delete fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "idisk.Delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,8 +696,7 @@ func (self *SRegion) DeleteVM(instanceId string) error {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil
|
||||
}
|
||||
log.Errorf("Fail to get instance status on DeleteVM: %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "self.GetInstanceStatus")
|
||||
}
|
||||
log.Debugf("Instance status on delete is %s", status)
|
||||
if status != InstanceStatusStopped {
|
||||
@@ -748,10 +747,11 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k
|
||||
}
|
||||
|
||||
func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
if err := self.host.zone.region.DeleteVM(self.InstanceId); err != nil {
|
||||
return err
|
||||
err := self.host.zone.region.DeleteVM(self.InstanceId)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "region.DeleteVM(%s)", self.InstanceId)
|
||||
}
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 300*time.Second) // 5minutes
|
||||
return cloudprovider.WaitDeleted(self, 10*time.Second, 10*time.Minute) // 5minutes
|
||||
}
|
||||
|
||||
func (self *SRegion) UpdateVM(instanceId string, name, osType string) error {
|
||||
|
||||
Reference in New Issue
Block a user