diff options
| author | Anthony Young <sleepsonthefloor@gmail.com> | 2011-01-13 14:14:19 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-01-13 14:14:19 +0000 |
| commit | c474cafe69fe71cbbfcf2a5a478f7708823e1f87 (patch) | |
| tree | 396ab939defa2015d654d933b2e8d097d791a63e | |
| parent | 621cf8e156582b3ff4dd44409324cc3a5f9aecf4 (diff) | |
| parent | f3332a1a63db657b84b52cf17ff46a853dfd063c (diff) | |
| download | nova-c474cafe69fe71cbbfcf2a5a478f7708823e1f87.tar.gz nova-c474cafe69fe71cbbfcf2a5a478f7708823e1f87.tar.xz nova-c474cafe69fe71cbbfcf2a5a478f7708823e1f87.zip | |
Fixes bug #701055. Moves code for instance termination inline so that the manager doesn't prematurely mark an instance as deleted. Prematurely doing so causes find calls to fail, prevents instance data from being deleted, and also causes some other issues.
| -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']) |
