-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retries for Barbican #289
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ | |
# under the License. | ||
|
||
import hashlib | ||
import tenacity | ||
from requests import exceptions as requests_exc | ||
from urllib3 import exceptions as urllib_exc | ||
|
||
from oslo_config import cfg | ||
from oslo_context import context as oslo_context | ||
|
@@ -23,6 +26,10 @@ | |
from octavia_f5.restclient.as3objects import certificate as m_cert | ||
|
||
CONF = cfg.CONF | ||
RETRY_ATTEMPTS = 15 | ||
RETRY_INITIAL_DELAY = 1 | ||
RETRY_BACKOFF = 1 | ||
RETRY_MAX = 5 | ||
|
||
|
||
class CertManagerWrapper(object): | ||
|
@@ -33,6 +40,13 @@ def __init__(self): | |
invoke_on_load=True, | ||
).driver | ||
|
||
@tenacity.retry( | ||
retry=tenacity.retry_if_exception_type( | ||
(urllib_exc.NewConnectionError, | ||
requests_exc.ConnectionError)), | ||
wait=tenacity.wait_incrementing( | ||
RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX), | ||
stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS)) | ||
def get_certificates(self, obj, context=None): | ||
"""Fetches certificates and creates dict out of octavia objects | ||
|
||
|
@@ -68,6 +82,13 @@ def get_certificates(self, obj, context=None): | |
|
||
return certificates | ||
|
||
@tenacity.retry( | ||
retry=tenacity.retry_if_exception_type( | ||
(urllib_exc.NewConnectionError, | ||
requests_exc.ConnectionError)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think these exceptions can occur here either. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, left comment to previous one. |
||
wait=tenacity.wait_incrementing( | ||
RETRY_INITIAL_DELAY, RETRY_BACKOFF, RETRY_MAX), | ||
stop=tenacity.stop_after_attempt(RETRY_ATTEMPTS)) | ||
def load_secret(self, project_id, secret_ref): | ||
"""Loads secrets from secret store | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_certificates
callscert_parser.load_certificates_data
(which is here), which catches all exceptions and raises only aCertificateRetrievalException
. Maybe I'm missing something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good catch. I checked the source class of Barbican https://github.com/sapcc/octavia/blob/600b5bae7537bc2fcf36c597818bfc4b7d48de10/octavia/certificates/manager/barbican.py#L97 but did not see that exception will be wrapped.