Merge "remove re-auth logic for ironic client"
This commit is contained in:
commit
99261e46b9
@ -37,10 +37,6 @@ class IronicClientWrapper(object):
|
|||||||
"""Initialise the IronicClientWrapper for use."""
|
"""Initialise the IronicClientWrapper for use."""
|
||||||
self._cached_client = None
|
self._cached_client = None
|
||||||
|
|
||||||
def _invalidate_cached_client(self):
|
|
||||||
"""Tell the wrapper to invalidate the cached ironic-client."""
|
|
||||||
self._cached_client = None
|
|
||||||
|
|
||||||
def _get_auth_plugin(self):
|
def _get_auth_plugin(self):
|
||||||
"""Load an auth plugin from CONF options."""
|
"""Load an auth plugin from CONF options."""
|
||||||
# If an auth plugin name is defined in `auth_type` option of [ironic]
|
# If an auth plugin name is defined in `auth_type` option of [ironic]
|
||||||
@ -115,21 +111,8 @@ class IronicClientWrapper(object):
|
|||||||
"""
|
"""
|
||||||
retry_on_conflict = kwargs.pop('retry_on_conflict', True)
|
retry_on_conflict = kwargs.pop('retry_on_conflict', True)
|
||||||
|
|
||||||
# NOTE(dtantsur): allow for authentication retry, other retries are
|
# authentication retry for token expiration is handled in keystone
|
||||||
# handled by ironicclient starting with 0.8.0
|
# session, other retries are handled by ironicclient starting with
|
||||||
for attempt in range(2):
|
# 0.8.0
|
||||||
client = self._get_client(retry_on_conflict=retry_on_conflict)
|
client = self._get_client(retry_on_conflict=retry_on_conflict)
|
||||||
|
return self._multi_getattr(client, method)(*args, **kwargs)
|
||||||
try:
|
|
||||||
return self._multi_getattr(client, method)(*args, **kwargs)
|
|
||||||
except ironic_exc.Unauthorized:
|
|
||||||
# In this case, the authorization token of the cached
|
|
||||||
# ironic-client probably expired. So invalidate the cached
|
|
||||||
# client and the next try will start with a fresh one.
|
|
||||||
if not attempt:
|
|
||||||
self._invalidate_cached_client()
|
|
||||||
LOG.debug("The Ironic client became unauthorized. "
|
|
||||||
"Will attempt to reauthorize and try again.")
|
|
||||||
else:
|
|
||||||
# This code should be unreachable actually
|
|
||||||
raise
|
|
||||||
|
Loading…
Reference in New Issue
Block a user