Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Jan 16, 2024
1 parent 27f5aac commit 5ed42b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions lib/charms/mongodb/v0/config_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from charms.mongodb.v1.helpers import add_args_to_env, get_mongos_args
from charms.mongodb.v1.mongos import MongosConnection
from ops.charm import CharmBase, EventBase
from ops.charm import CharmBase, EventBase, RelationBrokenEvent
from ops.framework import Object
from ops.model import ActiveStatus, MaintenanceStatus, WaitingStatus

Expand Down Expand Up @@ -233,10 +233,9 @@ def _on_relation_changed(self, event) -> None:

self.charm.unit.status = ActiveStatus()

def _on_relation_broken(self, event) -> None:
def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
# Only relation_deparated events can check if scaling down
departed_relation_id = event.relation.id
if not self.charm.has_departed_run(departed_relation_id):
if not self.charm.has_departed_run(event.relation.id):
logger.info(
"Deferring, must wait for relation departed hook to decide if relation should be removed."
)
Expand Down
3 changes: 1 addition & 2 deletions lib/charms/mongodb/v1/shards_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def pass_hook_checks(self, event: EventBase) -> bool:
return False

if isinstance(event, RelationBrokenEvent):
departed_relation_id = event.relation.id
if not self.charm.has_departed_run(departed_relation_id):
if not self.charm.has_departed_run(event.relation.id):
logger.info(
"Deferring, must wait for relation departed hook to decide if relation should be removed."
)
Expand Down
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ def set_scaling_down(self, event: RelationDepartedEvent) -> bool:
self.unit_peer_data[rel_departed_key] = json.dumps(scaling_down)
return scaling_down

def proceed_on_broken_event(self, event) -> int:
def proceed_on_broken_event(self, event) -> None:
"""Returns relation_id if relation broken event occurred due to a removed relation."""
departed_relation_id = None

Expand Down

0 comments on commit 5ed42b8

Please sign in to comment.