summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-10-14 16:15:25 -0500
committerJosh Kearney <josh@jk0.org>2011-10-14 16:16:13 -0500
commit1ebd98e3d20a35fc543800677cfe5e006a2f8cab (patch)
tree72f0be69cb43f7f0ab85ac5cff3e05c1da34359c
parent85fc484109d90ce8dcd714ef9d2df468bd54c7fe (diff)
Cancel any clean_reboot tasks before issuing the hard_reboot.
Fixes bug 873099. Change-Id: Id296cf60c832b31dd5320e119c797975d7a86299
-rw-r--r--nova/virt/xenapi/vmops.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 4f8cceb09..a0a7d9feb 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1133,12 +1133,27 @@ class VMOps(object):
vm_ref = self._get_vm_opaque_ref(instance)
self._start(instance, vm_ref)
+ def _cancel_stale_tasks(self, timeout, task):
+ """Cancel the given tasks that are older than the given timeout."""
+ task_refs = self._session.get_xenapi().task.get_by_name_label(task)
+ for task_ref in task_refs:
+ task_rec = self._session.get_xenapi().task.get_record(task_ref)
+ task_created = utils.parse_strtime(task_rec["created"].value,
+ "%Y%m%dT%H:%M:%SZ")
+
+ if utils.is_older_than(task_created, timeout):
+ self._session.get_xenapi().task.cancel(task_ref)
+
def poll_rebooting_instances(self, timeout):
"""Look for expirable rebooting instances.
- issue a "hard" reboot to any instance that has been stuck in a
reboot state for >= the given timeout
"""
+ # NOTE(jk0): All existing clean_reboot tasks must be cancelled before
+ # we can kick off the hard_reboot tasks.
+ self._cancel_stale_tasks(timeout, "Async.VM.clean_reboot")
+
ctxt = nova_context.get_admin_context()
instances = db.instance_get_all_hung_in_rebooting(ctxt, timeout)