mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Automatic merge from release/2.2.0 -> release/2.3.0
* commit '8c15c06a31ec97a16bf9434bbe23bc7b4d31937f': 修正:删除主机时,在停止主机时,如果宿主机不响应,应该导致删除失败
This commit is contained in:
@@ -141,12 +141,12 @@ func (self *SVirtualizedGuestDriver) StartGuestSyncstatusTask(guest *models.SGue
|
||||
}
|
||||
|
||||
func (self *SVirtualizedGuestDriver) RequestStopGuestForDelete(ctx context.Context, guest *models.SGuest, task taskman.ITask) error {
|
||||
guestStatus, _ := task.GetParams().GetString("guest_status")
|
||||
if guestStatus == models.VM_RUNNING {
|
||||
host := guest.GetHost()
|
||||
if host != nil && host.Enabled && host.HostStatus == models.HOST_ONLINE && !jsonutils.QueryBoolean(task.GetParams(), "purge", false) {
|
||||
return guest.StartGuestStopTask(ctx, task.GetUserCred(), true, task.GetTaskId())
|
||||
}
|
||||
host := guest.GetHost()
|
||||
if host != nil && host.Enabled && host.HostStatus == models.HOST_ONLINE {
|
||||
return guest.StartGuestStopTask(ctx, task.GetUserCred(), true, task.GetTaskId())
|
||||
}
|
||||
if !jsonutils.QueryBoolean(task.GetParams(), "purge", false) {
|
||||
return fmt.Errorf("fail to contact host")
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
|
||||
@@ -26,7 +26,11 @@ func init() {
|
||||
func (self *GuestDeleteTask) OnInit(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
guest := obj.(*models.SGuest)
|
||||
self.SetStage("on_guest_stop_complete", nil)
|
||||
guest.GetDriver().RequestStopGuestForDelete(ctx, guest, self)
|
||||
err := guest.GetDriver().RequestStopGuestForDelete(ctx, guest, self)
|
||||
if err != nil {
|
||||
errMsg := jsonutils.NewString(err.Error())
|
||||
self.OnGuestStopCompleteFailed(ctx, obj, errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *GuestDeleteTask) OnGuestStopComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
|
||||
Reference in New Issue
Block a user