diff options
author | Anthony Young <sleepsonthefloor@gmail.com> | 2011-01-13 01:25:08 +0000 |
---|---|---|
committer | Anthony Young <sleepsonthefloor@gmail.com> | 2011-01-13 01:25:08 +0000 |
commit | f3332a1a63db657b84b52cf17ff46a853dfd063c (patch) | |
tree | fcf0faae2d869ac44bc3f77aa2df9dab5808a3d0 | |
parent | 27369c18bde257c068ffc51e5ef51b479ad351d0 (diff) | |
download | nova-f3332a1a63db657b84b52cf17ff46a853dfd063c.tar.gz nova-f3332a1a63db657b84b52cf17ff46a853dfd063c.tar.xz nova-f3332a1a63db657b84b52cf17ff46a853dfd063c.zip |
Fixes #701055. Move instance termination code inline to prevent manager from prematurely marking it as destroyed.
-rw-r--r-- | nova/virt/libvirt_conn.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index bd863b3a2..c03046703 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -197,40 +197,27 @@ class LibvirtConnection(object): pass # If the instance is already terminated, we're still happy - done = event.Event() - # We'll save this for when we do shutdown, # instead of destroy - but destroy returns immediately timer = utils.LoopingCall(f=None) - def _wait_for_shutdown(): + while True: try: state = self.get_info(instance['name'])['state'] db.instance_set_state(context.get_admin_context(), instance['id'], state) if state == power_state.SHUTDOWN: - timer.stop() + break except Exception: db.instance_set_state(context.get_admin_context(), instance['id'], power_state.SHUTDOWN) - timer.stop() + break + + if cleanup: + self._cleanup(instance) - timer.f = _wait_for_shutdown - timer_done = timer.start(interval=0.5, now=True) - - # NOTE(termie): this is strictly superfluous (we could put the - # cleanup code in the timer), but this emulates the - # previous model so I am keeping it around until - # everything has been vetted a bit - def _wait_for_timer(): - timer_done.wait() - if cleanup: - self._cleanup(instance) - done.send() - - greenthread.spawn(_wait_for_timer) - return done + return True def _cleanup(self, instance): target = os.path.join(FLAGS.instances_path, instance['name']) |