Skip to content
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

Open
wants to merge 4 commits into
base: stable/yoga-m3
Choose a base branch
from
Open

Conversation

velp
Copy link
Contributor

@velp velp commented Feb 25, 2025

This PR adds a simple retries mechanism for requests to Barbican. Hardcoded values were used to keep the same style for calls of this decorator: https://github.com/search?q=repo%3Asapcc%2Foctavia-f5-provider-driver%20%22tenacity.retry%22&type=code

Comment on lines 45 to 46
(urllib_exc.NewConnectionError,
requests_exc.ConnectionError)),
Copy link
Collaborator

@BenjaminLudwigSAP BenjaminLudwigSAP Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Why did you decide on these two exceptions? Where are they thrown?
  • I don't think these exceptions can occur here. Because get_certificates calls cert_parser.load_certificates_data (which is here), which catches all exceptions and raises only a CertificateRetrievalException. Maybe I'm missing something?

Copy link
Contributor Author

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.

Comment on lines 87 to 88
(urllib_exc.NewConnectionError,
requests_exc.ConnectionError)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these exceptions can occur here either. Because load_secret calls self.cert_manager.get_secret, which defaults to this function here, which catches all exceptions and raises only a CertificateRetrievalException. Maybe I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, left comment to previous one.

Copy link
Collaborator

@BenjaminLudwigSAP BenjaminLudwigSAP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one optional note, but all in all it looks fine to me 👍 Thanks.

@@ -33,6 +39,12 @@ def __init__(self):
invoke_on_load=True,
).driver

@tenacity.retry(
retry=tenacity.retry_if_exception_type(
(octavia_exc.CertificateRetrievalException)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand it from the Tenacity docs, this does not have to be a tuple, so you can leave out the parentheses here. But it's okay if you don't, I'm still approving this PR 👍

@@ -68,6 +80,12 @@ def get_certificates(self, obj, context=None):

return certificates

@tenacity.retry(
retry=tenacity.retry_if_exception_type(
(octavia_exc.CertificateRetrievalException)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants