From 284c581845201d89c9c2f4934ae5a338bcc23f61 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 15 Jun 2021 00:23:15 -0400 Subject: [PATCH] Ensure shutdown migrations actually time out Without this a VM that fails to respond to a shutdown will just spin forever, blocking state changes. --- node-daemon/pvcnoded/VMInstance.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/node-daemon/pvcnoded/VMInstance.py b/node-daemon/pvcnoded/VMInstance.py index 2d93442f..e00f967e 100644 --- a/node-daemon/pvcnoded/VMInstance.py +++ b/node-daemon/pvcnoded/VMInstance.py @@ -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