避免无限删除guest失败

This commit is contained in:
ioito
2019-07-10 15:17:21 +08:00
parent 0f0a0902bc
commit 0b0cddd2be
2 changed files with 11 additions and 0 deletions
@@ -152,6 +152,10 @@ func (self *SManagedVirtualizedGuestDriver) RequestDetachDisk(ctx context.Contex
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
iVM, err := guest.GetIVM()
if err != nil {
//若guest被删除,忽略错误,否则会无限删除guest失败(有挂载的云盘)
if err == cloudprovider.ErrNotFound {
return nil, nil
}
return nil, errors.Wrapf(err, "guest.GetIVM")
}
if len(disk.ExternalId) == 0 {
@@ -522,6 +526,10 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
ihost, err := host.GetIHost()
if err != nil {
//私有云宿主机有可能下线,会导致虚拟机无限删除失败
if err == cloudprovider.ErrNotFound {
return nil, nil
}
log.Errorf("host.GetIHost fail %s", err)
return nil, err
}
+3
View File
@@ -2198,6 +2198,9 @@ func (self *SHost) GetIHostAndProvider() (cloudprovider.ICloudHost, cloudprovide
}
ihost, err := iregion.GetIHostById(self.ExternalId)
if err != nil {
if err == cloudprovider.ErrNotFound {
return nil, nil, cloudprovider.ErrNotFound
}
log.Errorf("fail to find ihost by id %s %s", self.ExternalId, err)
return nil, nil, fmt.Errorf("fail to find ihost by id %s", err)
}