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

Gracefully handle when the remote unit/app is already gone #108

Merged
merged 1 commit into from May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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