Commit e0561198 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix two race conditions in reboot instance

If the instance crashes between backend.InstanceReboot checks the list
of running instances and the execution of hv_xen.RebootInstance,
ini_info will be None. And if the instance doesn't reboot fast enough,
new_info will be None. Both cases lead to “TypeError: unsubscriptable
object”. Too bad pylint doesn't detect such cases.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 31d97b2a
......@@ -213,6 +213,10 @@ class XenHypervisor(hv_base.BaseHypervisor):
ini_info = self.GetInstanceInfo(
if ini_info is None:
raise errors.HypervisorError("Failed to reboot instance %s,"
" not running" %
result = utils.RunCmd(["xm", "reboot",])
if result.failed:
raise errors.HypervisorError("Failed to reboot instance %s: %s, %s" %
......@@ -223,7 +227,8 @@ class XenHypervisor(hv_base.BaseHypervisor):
new_info = self.GetInstanceInfo(
# check if the domain ID has changed or the run time has decreased
if new_info[1] != ini_info[1] or new_info[5] < ini_info[5]:
if (new_info is not None and
(new_info[1] != ini_info[1] or new_info[5] < ini_info[5])):
raise utils.RetryAgain()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment