Skip to content

Commit

Permalink
fix(region): sync managed vm status (#21750)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Dec 5, 2024
1 parent 460e1e5 commit c4c1f1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/compute/guestdrivers/managedvirtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,13 +1409,15 @@ func (self *SManagedVirtualizedGuestDriver) requestMigrate(ctx context.Context,
return false, err
}
vmStatus := iVM.GetStatus()
log.Debugf("vm %s migrate status: %s", guest.Name, vmStatus)
if vmStatus == api.VM_UNKNOWN || strings.Contains(vmStatus, "fail") {
return false, errors.Wrapf(cloudprovider.ErrInvalidStatus, vmStatus)
}
if !utils.IsInStringArray(vmStatus, []string{api.VM_RUNNING, api.VM_READY}) {
return false, nil
}
hostId := iVM.GetIHostId()
log.Debugf("guest %s migrate from %s -> %s", guest.Name, hostExternalId, hostId)
if len(hostId) > 0 && hostId != hostExternalId {
hostExternalId = hostId
return true, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/tasks/guest_syncstatus_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (self *GuestSyncstatusTask) OnGetStatusComplete(ctx context.Context, obj db
// not change migrating when:
// guest.Status is migrating and task not has parent task
os := self.getOriginStatus()
if os == api.VM_MIGRATING && statusStr == api.VM_RUNNING {
if os == api.VM_MIGRATING && statusStr == api.VM_RUNNING && len(guest.ExternalId) == 0 {
statusStr = os
}
}
Expand Down

0 comments on commit c4c1f1c

Please sign in to comment.