From: Steven Dake Date: Thu, 12 Jul 2012 15:38:51 +0000 (-0700) Subject: Block on instance delete until delete operation completes X-Git-Tag: 2014.1~1605 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=581b0c6f6adc4480fc7c03eb96abda821c89b1a7;p=openstack-build%2Fheat-build.git Block on instance delete until delete operation completes Fixes issue #160 During deletion of a stack, following would occur: delete stack delete instance delete eip or security group When the last operation occurred, the instance is still present in OpenStack making a deletion of EIP or security groups not work properly. Serialize the operations in resources. Change-Id: I6e1613f5a6f5db485dd8a5f381d7a96afb58188b Signed-off-by: Steven Dake --- diff --git a/heat/engine/instance.py b/heat/engine/instance.py index c48aa643..a1c794de 100644 --- a/heat/engine/instance.py +++ b/heat/engine/instance.py @@ -280,10 +280,19 @@ class Instance(resources.Resource): 'Provided KeyName is not registered with nova'} def handle_delete(self): + ''' + Delete an instance, blocking until it is disposed by OpenStack + ''' try: server = self.nova().servers.get(self.instance_id) except NotFound: pass else: server.delete() + while server.status == 'ACTIVE': + try: + server.get() + except NotFound: + break + eventlet.sleep(0.2) self.instance_id = None