Catch RetriableConnectionFailures from KAuth and retry
Some keystone auth failures are retriable, this patch ensures that when ironiclient retries are turned on, we also retry on those failures. Change-Id: I7181b2aa4c8d0cc3b5523cb913562bee2e1955a2 Closes-Bug: #1537076
This commit is contained in:
parent
7623bc6197
commit
11a3f12c3a
@ -26,6 +26,7 @@ import textwrap
|
||||
import time
|
||||
|
||||
from keystoneauth1 import adapter
|
||||
from keystoneauth1 import exceptions as kexc
|
||||
from oslo_utils import strutils
|
||||
import requests
|
||||
import six
|
||||
@ -171,7 +172,7 @@ class VersionNegotiationMixin(object):
|
||||
|
||||
|
||||
_RETRY_EXCEPTIONS = (exc.Conflict, exc.ServiceUnavailable,
|
||||
exc.ConnectionRefused)
|
||||
exc.ConnectionRefused, kexc.RetriableConnectionFailure)
|
||||
|
||||
|
||||
def with_retries(func):
|
||||
|
@ -20,6 +20,8 @@ import mock
|
||||
import six
|
||||
from six.moves import http_client
|
||||
|
||||
from keystoneauth1 import exceptions as kexc
|
||||
|
||||
from ironicclient.common import filecache
|
||||
from ironicclient.common import http
|
||||
from ironicclient import exc
|
||||
@ -727,6 +729,19 @@ class RetriesTestCase(utils.BaseTestCase):
|
||||
client.json_request('GET', '/v1/resources')
|
||||
self.assertEqual(2, fake_session.request.call_count)
|
||||
|
||||
def test_session_retry_retriable_connection_failure(self):
|
||||
ok_resp = utils.FakeSessionResponse(
|
||||
{'Content-Type': 'application/json'},
|
||||
b"OK",
|
||||
http_client.OK)
|
||||
fake_session = mock.Mock(spec=utils.FakeSession)
|
||||
fake_session.request.side_effect = iter(
|
||||
(kexc.RetriableConnectionFailure(), ok_resp))
|
||||
|
||||
client = _session_client(session=fake_session)
|
||||
client.json_request('GET', '/v1/resources')
|
||||
self.assertEqual(2, fake_session.request.call_count)
|
||||
|
||||
def test_session_retry_fail(self):
|
||||
error_body = _get_error_body()
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- The client will now retry on keystoneauth retriable connection failures if
|
||||
retries are enabled for a particular request. This ensures that on a
|
||||
temporary network outage to the keystone auth services a request we be
|
||||
retried the requested number of times before raising an exception.
|
Loading…
Reference in New Issue
Block a user