From bb92e62581a5241a581af9b243615839ebafa685 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Wed, 20 Jun 2012 12:23:55 +1000 Subject: [PATCH] Work around keystone strangeness (error deleting user) Fixes: #144 Change-Id: Ib9298605accc3fc7d12112a4fb57df2b4746864a Signed-off-by: Angus Salkeld --- heat/engine/user.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/heat/engine/user.py b/heat/engine/user.py index d0c3cb6e6b..0c2a252b69 100644 --- a/heat/engine/user.py +++ b/heat/engine/user.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import eventlet import logging from heat.common import exception from heat.engine.resources import Resource @@ -64,8 +65,33 @@ class User(Resource): except Exception as ex: logger.info('user %s/%s does not exist' % (self.name, self.instance_id)) - else: - user.delete() + return + + # tempory hack to work around an openstack bug. + # seems you can't delete a user first time - you have to try + # a couple of times - go figure! + tmo = eventlet.Timeout(10) + status = 'WAITING' + reason = 'Timed out trying to delete user' + try: + while status == 'WAITING': + try: + user.delete() + status = 'DELETED' + except Exception as ce: + reason = str(ce) + eventlet.sleep(1) + except eventlet.Timeout as t: + if t is not tmo: + # not my timeout + raise + else: + status = 'TIMEDOUT' + finally: + tmo.cancel() + + if status != 'DELETED': + raise exception.Error(reason) def FnGetRefId(self): return unicode(self.name)