From 306a14f69a2a83135291d53b7f165e0d956fb9a6 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Fri, 24 Apr 2015 14:51:44 +0300 Subject: [PATCH] Adding retry ability to keystoneclient calls All keystoneclient calls wrapped in execute_with_retry method to avoid occasional errors partially implements bp clients-calls-retry Change-Id: I3d7f09c8b867ef7b7766295815e71fd1083a14c1 --- sahara/swift/utils.py | 3 ++- sahara/utils/proxy.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sahara/swift/utils.py b/sahara/swift/utils.py index 5ef342ed..d69cfef2 100644 --- a/sahara/swift/utils.py +++ b/sahara/swift/utils.py @@ -58,7 +58,8 @@ def retrieve_preauth_url(): ''' client = k.client() - catalog = client.service_catalog.get_endpoints('object-store') + catalog = clients_base.execute_with_retries( + client.service_catalog.get_endpoints, 'object-store') for ep in catalog.get('object-store'): if ep.get('interface') == 'public': return ep.get('url') diff --git a/sahara/utils/proxy.py b/sahara/utils/proxy.py index be713a48..a3c0d204 100644 --- a/sahara/utils/proxy.py +++ b/sahara/utils/proxy.py @@ -26,6 +26,7 @@ from sahara.i18n import _ from sahara.service.edp import job_utils from sahara.service import trusts as t from sahara.swift import utils as su +from sahara.utils.openstack import base as b from sahara.utils.openstack import keystone as k @@ -165,7 +166,8 @@ def domain_for_proxy(): global PROXY_DOMAIN if not PROXY_DOMAIN: - domain_list = admin.domains.list(name=CONF.proxy_user_domain_name) + domain_list = b.execute_with_retries( + admin.domains.list, name=CONF.proxy_user_domain_name) if len(domain_list) == 0: raise ex.NotFoundException(value=CONF.proxy_user_domain_name, message=_('Failed to find domain %s')) @@ -246,7 +248,7 @@ def proxy_domain_users_list(): admin = k.client_for_admin() domain = domain_for_proxy() if domain: - return admin.users.list(domain=domain.id) + return b.execute_with_retries(admin.users.list, domain=domain.id) return [] @@ -262,7 +264,8 @@ def proxy_user_create(username): admin = k.client_for_admin() domain = domain_for_proxy() password = six.text_type(uuid.uuid4()) - admin.users.create(name=username, password=password, domain=domain.id) + b.execute_with_retries( + admin.users.create, name=username, password=password, domain=domain.id) LOG.debug('Created proxy user {username}'.format(username=username)) return password @@ -280,7 +283,8 @@ def proxy_user_delete(username=None, user_id=None): admin = k.client_for_admin() if not user_id: domain = domain_for_proxy() - user_list = admin.users.list(domain=domain.id, name=username) + user_list = b.execute_with_retries( + admin.users.list, domain=domain.id, name=username) if len(user_list) == 0: raise ex.NotFoundException(value=username, message=_('Failed to find user %s')) @@ -289,5 +293,5 @@ def proxy_user_delete(username=None, user_id=None): message=_('Unexpected results found ' 'when searching for user %s')) user_id = user_list[0].id - admin.users.delete(user_id) + b.execute_with_retries(admin.users.delete, user_id) LOG.debug('Deleted proxy user id {user_id}'.format(user_id=user_id))