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

barbican fallback to legacy only if not found #40

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion octavia/certificates/manager/barbican.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
from OpenSSL import crypto

from barbicanclient import exceptions as barbican_exceptions
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import encodeutils
Expand Down Expand Up @@ -115,7 +116,15 @@ def get_cert(self, context, cert_ref, resource_ref=None, check_only=False,
return pkcs12.PKCS12Cert(cert_secret.payload)
except exceptions.UnreadablePKCS12:
raise
except Exception:
except barbican_exceptions.HTTPClientError as e:
# we only want to try the legacy (container) based retrieval if the pkcs12 cert is not found,
# else, just raise the error so we retry the pkcs12 retrieval again
if e.status_code != 404:
raise

LOG.warning('Failed to load PKCS12Cert for secret %s with %s',
cert_ref, str(e))
LOG.warning('Falling back to the barbican_legacy implementation.')
# If our get fails, try with the legacy driver.
# TODO(rm_work): Remove this code when the deprecation cycle for
# the legacy driver is complete.
Expand Down
Loading