mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix guest cannot delete
This commit is contained in:
@@ -318,6 +318,20 @@ func (self *SKVMGuestDriver) RequestSoftReset(ctx context.Context, guest *models
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) RequestDetachDisk(ctx context.Context, guest *models.SGuest, disk *models.SDisk, task taskman.ITask) error {
|
||||
host := guest.GetHost()
|
||||
header := task.GetTaskRequestHeader()
|
||||
url := fmt.Sprintf("%s/servers/%s/status", host.ManagerUri, guest.Id)
|
||||
_, res, _ := httputils.JSONRequest(httputils.GetDefaultClient(), ctx, "GET", url, header, nil, false)
|
||||
if res != nil {
|
||||
status, _ := res.GetString("status")
|
||||
if status == "notfound" {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
return nil, nil
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
return guest.StartSyncTask(ctx, task.GetUserCred(), false, task.GetTaskId())
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@ func (self *GuestDetachDiskTask) OnInit(ctx context.Context, obj db.IStandaloneM
|
||||
|
||||
if !purge {
|
||||
self.SetStage("OnDetachDiskComplete", nil)
|
||||
guest.GetDriver().RequestDetachDisk(ctx, guest, disk, self)
|
||||
if err := guest.GetDriver().RequestDetachDisk(ctx, guest, disk, self); err != nil {
|
||||
self.OnTaskFail(ctx, guest, disk, err)
|
||||
}
|
||||
} else {
|
||||
self.OnDetachDiskComplete(ctx, guest, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user