Ensure shutdown migrations actually time out

Without this a VM that fails to respond to a shutdown will just spin
forever, blocking state changes.
This commit is contained in:
Joshua Boniface 2021-06-15 00:23:15 -04:00
parent 7b85d5e3f3
commit 284c581845
1 changed files with 12 additions and 0 deletions

View File

@ -531,8 +531,20 @@ class VMInstance(object):
self.zkhandler.write([
(('domain.state', self.domuuid), 'shutdown')
])
ticks = 0
while self.zkhandler.read(('domain.state', self.domuuid)) != 'stop':
ticks += 1
if ticks > self.config['vm_shutdown_timeout'] * 2:
# We've hit the timeout, forcibly stop the VM and continue
self.zkhandler.write([
(('domain.state', self.domuuid), 'stop')
])
# Wait 1/2 of a second for the state propagation
time.sleep(0.5)
break
time.sleep(0.5)
return True
do_migrate_shutdown = False