mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #2689 from ioito/hotifx/qx-guest-delete-fix
fix: 避免裸金属服务器转宿主机任务失败
This commit is contained in:
@@ -527,6 +527,15 @@ func (guest *SGuest) ValidatePurgeCondition(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (guest *SGuest) ValidateDeleteCondition(ctx context.Context) error {
|
||||
host := guest.GetHost()
|
||||
if host != nil {
|
||||
if !host.Enabled {
|
||||
return httperrors.NewInputParameterError("Cannot delete server on disabled host")
|
||||
}
|
||||
if host.HostStatus != api.HOST_ONLINE {
|
||||
return httperrors.NewInputParameterError("Cannot delete server on offline host")
|
||||
}
|
||||
}
|
||||
return guest.validateDeleteCondition(ctx, false)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ package tasks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
@@ -49,10 +48,6 @@ func (self *GuestUndeployTask) OnInit(ctx context.Context, obj db.IStandaloneMod
|
||||
host = models.HostManager.FetchHostById(targetHostId)
|
||||
}
|
||||
if host != nil {
|
||||
if !host.Enabled {
|
||||
self.OnStartDeleteGuestFail(ctx, fmt.Errorf("host %s(%s) is disabled", host.Name, host.Id))
|
||||
return
|
||||
}
|
||||
err := guest.GetDriver().RequestUndeployGuestOnHost(ctx, guest, host, self)
|
||||
if err != nil {
|
||||
self.OnStartDeleteGuestFail(ctx, err)
|
||||
@@ -66,10 +61,6 @@ func (self *GuestUndeployTask) OnMasterHostUndeployGuestComplete(ctx context.Con
|
||||
self.SetStage("OnGuestUndeployComplete", nil)
|
||||
host := models.HostManager.FetchHostById(guest.BackupHostId)
|
||||
if host != nil {
|
||||
if !host.Enabled {
|
||||
self.OnStartDeleteGuestFail(ctx, fmt.Errorf("host %s(%s) is disabled", host.Name, host.Id))
|
||||
return
|
||||
}
|
||||
err := guest.GetDriver().RequestUndeployGuestOnHost(ctx, guest, host, self)
|
||||
if err != nil {
|
||||
self.OnStartDeleteGuestFail(ctx, err)
|
||||
|
||||
Reference in New Issue
Block a user