6868
6969LIBID = "b5cd5cd580f3428fa5f59a8876dcbe6a"
7070LIBAPI = 1
71- LIBPATCH = 14
71+ LIBPATCH = 15
7272
7373VAULT_SECRET_LABEL = "cert-handler-private-vault"
7474
@@ -127,7 +127,7 @@ class _RelationVaultBackend(_VaultBackend):
127127 _NEST_UNDER = "lib.charms.observability_libs.v1.cert_handler::vault"
128128 # This key needs to be relation-unique. If someone ever creates multiple Vault(_RelationVaultBackend)
129129 # instances backed by the same (peer) relation, they'll need to set different _NEST_UNDERs
130- # for each _RelationVaultBackend instance or they'll be fighting over it.
130+ # for each _RelationVaultBackend instance, or they'll be fighting over it.
131131
132132 def __init__ (self , charm : CharmBase , relation_name : str ):
133133 self .charm = charm
@@ -344,6 +344,13 @@ def __init__(
344344 self .charm .on [self .certificates_relation_name ].relation_joined , # pyright: ignore
345345 self ._on_certificates_relation_joined ,
346346 )
347+ # The following observer is a workaround. The tls-certificates lib sometimes fails to emit the custom
348+ # "certificate_available" event on relation changed. Not sure why this was happening. We certainly have some
349+ # tech debt here to address, but this workaround proved to work.
350+ self .framework .observe (
351+ self .charm .on [self .certificates_relation_name ].relation_changed , # pyright: ignore
352+ self ._on_certificate_available ,
353+ )
347354 self .framework .observe (
348355 self .certificates .on .certificate_available , # pyright: ignore
349356 self ._on_certificate_available ,
@@ -366,7 +373,7 @@ def __init__(
366373 )
367374
368375 if refresh_events :
369- logger .warn (
376+ logger .warning (
370377 "DEPRECATION WARNING. `refresh_events` is now deprecated. CertHandler will automatically refresh the CSR when necessary."
371378 )
372379
@@ -429,7 +436,7 @@ def enabled(self) -> bool:
429436 See also the `available` property.
430437 """
431438 # We need to check for units as a temporary workaround because of https://bugs.launchpad.net/juju/+bug/2024583
432- # This could in theory not work correctly on scale down to 0 but it is necessary for the moment.
439+ # This could in theory not work correctly on scale down to 0, but it is necessary for the moment.
433440
434441 if not self .relation :
435442 return False
@@ -636,7 +643,7 @@ def _on_all_certificates_invalidated(self, _: AllCertificatesInvalidatedEvent) -
636643 # Note: assuming "limit: 1" in metadata
637644 # The "certificates_relation_broken" event is converted to "all invalidated" custom
638645 # event by the tls-certificates library. Per convention, we let the lib manage the
639- # relation and we do not observe "certificates_relation_broken" directly.
646+ # relation, and we do not observe "certificates_relation_broken" directly.
640647 self .vault .clear ()
641648 # We do not generate a CSR here because the relation is gone.
642649 self .on .cert_changed .emit () # pyright: ignore
0 commit comments