Skip to content

Commit

Permalink
Add retries for Barbican
Browse files Browse the repository at this point in the history
  • Loading branch information
velp committed Feb 25, 2025
1 parent ceb09b7 commit da20033
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions octavia_f5/utils/cert_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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)),
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
Expand Down

0 comments on commit da20033

Please sign in to comment.