Skip to content

Commit

Permalink
Merge pull request #108 from simondeziel/https-teardown-fixes
Browse files Browse the repository at this point in the history
Gracefully handle when the remote unit/app is already gone
  • Loading branch information
Stéphane Graber committed May 4, 2023
2 parents cc8aeeb + 0d9dc7a commit d48d58d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/charm.py
Expand Up @@ -995,6 +995,10 @@ def _on_https_relation_broken(self, event: RelationBrokenEvent) -> None:
if not self.unit.is_leader() or not self._stored.lxd_clustered:
return

if not event.app:
logger.warning("Unable to remove the client certificate of the departed app")
return

fingerprint: str = self.lxd_trust_fingerprint(f"juju-relation-{event.app.name}")
if fingerprint:
self.lxd_trust_remove(fingerprint)
Expand Down Expand Up @@ -1105,6 +1109,10 @@ def _on_https_relation_departed(self, event: RelationDepartedEvent) -> None:
if not self.unit.is_leader() or not self._stored.lxd_clustered:
return

if not event.unit:
logger.warning("Unable to remove the client certificate of the departed unit")
return

fingerprint: str = self.lxd_trust_fingerprint(f"juju-relation-{event.unit.name}")
if fingerprint:
self.lxd_trust_remove(fingerprint)
Expand Down

0 comments on commit d48d58d

Please sign in to comment.