Merge "remove re-auth logic for ironic client wrapper"
This commit is contained in:
commit
faede889d3
|
@ -114,15 +114,6 @@ class IronicClientWrapperTestCase(test.NoDBTestCase):
|
|||
second_client = ironicclient._get_client()
|
||||
self.assertEqual(id(first_client), id(second_client))
|
||||
|
||||
@mock.patch.object(ironic_client, 'get_client')
|
||||
def test__invalidate_cached_client(self, mock_get_client):
|
||||
mock_get_client.side_effect = get_new_fake_client
|
||||
ironicclient = client_wrapper.IronicClientWrapper()
|
||||
first_client = ironicclient._get_client()
|
||||
ironicclient._invalidate_cached_client()
|
||||
second_client = ironicclient._get_client()
|
||||
self.assertNotEqual(id(first_client), id(second_client))
|
||||
|
||||
@mock.patch.object(ironic_client, 'get_client')
|
||||
def test_call_uses_cached_client(self, mock_get_client):
|
||||
mock_get_client.side_effect = get_new_fake_client
|
||||
|
|
|
@ -54,10 +54,6 @@ class IronicClientWrapper(object):
|
|||
'ironicclient.client')
|
||||
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):
|
||||
"""Load an auth plugin from CONF options."""
|
||||
# If an auth plugin name is defined in `auth_type` option of [ironic]
|
||||
|
@ -137,21 +133,8 @@ class IronicClientWrapper(object):
|
|||
"""
|
||||
retry_on_conflict = kwargs.pop('retry_on_conflict', True)
|
||||
|
||||
# NOTE(dtantsur): allow for authentication retry, other retries are
|
||||
# handled by ironicclient starting with 0.8.0
|
||||
for attempt in range(2):
|
||||
client = self._get_client(retry_on_conflict=retry_on_conflict)
|
||||
|
||||
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
|
||||
# authentication retry for token expiration is handled in keystone
|
||||
# session, other retries are handled by ironicclient starting with
|
||||
# 0.8.0
|
||||
client = self._get_client(retry_on_conflict=retry_on_conflict)
|
||||
return self._multi_getattr(client, method)(*args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue