Work around keystone strangeness (error deleting user)

Fixes: #144

Change-Id: Ib9298605accc3fc7d12112a4fb57df2b4746864a
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
changes/02/202/1
Angus Salkeld 10 years ago
parent 3df9355a68
commit bb92e62581
  1. 30
      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)

Loading…
Cancel
Save