Skip to content

Commit

Permalink
Moving clearing of blocked status from _on_relation_departed to _on_r…
Browse files Browse the repository at this point in the history
…elation_broken (#79)
  • Loading branch information
dragomirp authored Jan 18, 2023
1 parent 5ebd46e commit 2a805ab
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/relations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,6 @@ def _on_relation_departed(self, event: RelationDepartedEvent) -> None:
{unit for unit in current_allowed_units.split() if unit != departing_unit}
)

# Clean up Blocked status if caused by the departed relation
if (
self.charm._has_blocked_status
and self.charm.unit.status.message == EXTENSIONS_BLOCKING_MESSAGE
):
if "extensions" in event.relation.data.get(
event.app, {}
) or "extensions" in event.relation.data.get(event.unit, {}):
if not self._check_for_blocking_relations(event.relation.id):
self.charm.unit.status = ActiveStatus()

def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
"""Remove the user created for this relation."""
# Check for some conditions before trying to access the PostgreSQL instance.
Expand All @@ -260,6 +249,17 @@ def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
f"Failed to delete user during {self.relation_name} relation broken event"
)

# Clean up Blocked status if caused by the departed relation
if (
self.charm._has_blocked_status
and self.charm.unit.status.message == EXTENSIONS_BLOCKING_MESSAGE
):
if "extensions" in event.relation.data.get(
event.app, {}
) or "extensions" in event.relation.data.get(event.unit, {}):
if not self._check_for_blocking_relations(event.relation.id):
self.charm.unit.status = ActiveStatus()

def _get_allowed_subnets(self, relation: Relation) -> str:
"""Build the list of allowed subnets as in the legacy charm."""

Expand Down

0 comments on commit 2a805ab

Please sign in to comment.