Fix bugs for node flush for stop/shutdown/restart
Previously VMs in stop/shutdown/restart states wouldn't be properly handled during a node flush. This fixes the bugs and ensures that the transient VM states (shutdown/restart) are completed before proceeding, and then avoids setting a stopped/shutdown VM to shutdown/auotstart.
This commit is contained in:
parent
3a4914fa5e
commit
b5f996febd
|
@ -790,6 +790,19 @@ class NodeInstance(object):
|
||||||
self.flush_stopper = False
|
self.flush_stopper = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Wait for a VM in "restart" or "shutdown" state to complete transition
|
||||||
|
while self.zkhandler.read(("domain.state", dom_uuid)) in [
|
||||||
|
"restart",
|
||||||
|
"shutdown",
|
||||||
|
]:
|
||||||
|
self.logger.out(
|
||||||
|
'Waiting 2s for VM state change completion for VM "{}"'.format(
|
||||||
|
dom_uuid
|
||||||
|
),
|
||||||
|
state="i",
|
||||||
|
)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
self.logger.out(
|
self.logger.out(
|
||||||
'Selecting target to migrate VM "{}"'.format(dom_uuid), state="i"
|
'Selecting target to migrate VM "{}"'.format(dom_uuid), state="i"
|
||||||
)
|
)
|
||||||
|
@ -806,11 +819,13 @@ class NodeInstance(object):
|
||||||
|
|
||||||
if target_node is None:
|
if target_node is None:
|
||||||
self.logger.out(
|
self.logger.out(
|
||||||
'Failed to find migration target for VM "{}"; shutting down and setting autostart flag'.format(
|
'Failed to find migration target for running VM "{}"; shutting down and setting autostart flag'.format(
|
||||||
dom_uuid
|
dom_uuid
|
||||||
),
|
),
|
||||||
state="e",
|
state="e",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.zkhandler.read(("domain.state", dom_uuid)) in ["start"]:
|
||||||
self.zkhandler.write(
|
self.zkhandler.write(
|
||||||
[
|
[
|
||||||
(("domain.state", dom_uuid), "shutdown"),
|
(("domain.state", dom_uuid), "shutdown"),
|
||||||
|
|
Loading…
Reference in New Issue