diff options
author | Julia Kreger <juliaashleykreger@gmail.com> | 2021-12-01 14:20:35 -0800 |
---|---|---|
committer | Julia Kreger <juliaashleykreger@gmail.com> | 2021-12-07 11:02:49 -0800 |
commit | 3e3afc3254aa7bf2c27033ac9f0aa5f503dff9b0 (patch) | |
tree | 9c22060fe9c6de7fbd49507933c243d276bcd40c /ironic/drivers/modules/redfish/utils.py | |
parent | 0df43f7586f93ab54d533201de21ed7ed95ec182 (diff) | |
download | ironic-3e3afc3254aa7bf2c27033ac9f0aa5f503dff9b0.tar.gz |
Remove redfish cache entry upon errors
Some transient errors can ultimately cause the client to need to be
completely restarted due to cached connection data.
Ironic now explicitly removes the cache entry when a sushy
AccessError or python AttributeError is detected originating
from the library. This will now result in the prior cached connection
object to be discarded, and upon the next attempt to interact with
the same node, a new connection will be launched.
This will result in new sessions being created, but in all likelihood
the prior session had already timed out or had been administratively
removed. Sushy's code, as of
https://review.opendev.org/c/openstack/sushy/+/820076
will raise SessionService lookup access errors as AccessErrors.
Prior to that change, they should have been raised as AttributeError
as the previous call sould have returned None to be used as an object.
*Also* Includes follow-up change Ia59f774c9340e3a6fa63418afedf12098c709052
squashed into this change, and necessary backport friendly mock of
AccessError which had changed since this release of ironic.
Change-Id: Icc6e5dd74d9f15e679a7e764fe49238ed6b8dc1e
Story: 2009719
Task: 44107
(cherry picked from commit 1439af27ba2bd31fb85369754c648a45ee9ca14b)
(cherry picked from commit 01997c8418b9e6ade47437b09dd9412310b90eac)
(cherry picked from commit e3e7deaf48a5315fe10350e8a87b2fcc4e189406)
(cherry picked from commit ab5495eecb409b37ad853a679032d6cdb4fefc72)
(cherry picked from commit e57aa7598b220bb2d1fd8fcc0aab6132926d5cce)
Diffstat (limited to 'ironic/drivers/modules/redfish/utils.py')
-rw-r--r-- | ironic/drivers/modules/redfish/utils.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ironic/drivers/modules/redfish/utils.py b/ironic/drivers/modules/redfish/utils.py index 705fc997e..29aca761f 100644 --- a/ironic/drivers/modules/redfish/utils.py +++ b/ironic/drivers/modules/redfish/utils.py @@ -233,6 +233,16 @@ class SessionCache(object): # NOTE(etingof): perhaps this session token is no good if isinstance(exc_val, sushy.exceptions.ConnectionError): self.__class__._sessions.pop(self._session_key, None) + # NOTE(TheJulia): A hard access error has surfaced, we + # likely need to eliminate the session. + if isinstance(exc_val, sushy.exceptions.AccessError): + self.__class__._sessions.pop(self._session_key, None) + # NOTE(TheJulia): Something very bad has happened, such + # as the session is out of date, and refresh of the SessionService + # failed resulting in an AttributeError surfacing. + # https://storyboard.openstack.org/#!/story/2009719 + if isinstance(exc_val, AttributeError): + self.__class__._sessions.pop(self._session_key, None) @classmethod def _expire_oldest_session(cls): @@ -321,6 +331,23 @@ def _get_connection(node, lambda_fun, *args): 'auth_type': driver_info['auth_type'], 'node': node.uuid, 'error': e}) raise exception.RedfishConnectionError(node=node.uuid, error=e) + except sushy.exceptions.AccessError as e: + LOG.warning('For node %(node)s, we received an authentication ' + 'access error from address %(address)s with auth_type ' + '%(auth_type)s. The client will not be re-used upon ' + 'the next re-attempt. Please ensure your using the ' + 'correct credentials. Error: %(error)s', + {'address': driver_info['address'], + 'auth_type': driver_info['auth_type'], + 'node': node.uuid, 'error': e}) + raise exception.RedfishError(node=node.uuid, error=e) + except AttributeError as e: + LOG.warning('For node %(node)s, we received at AttributeError ' + 'when attempting to utilize the client. A new ' + 'client session shall be used upon the next attempt.' + 'Attribute Error: %(error)s', + {'node': node.uuid, 'error': e}) + raise exception.RedfishError(node=node.uuid, error=e) try: return _get_cached_connection(lambda_fun, *args) |