Skip to content

Commit

Permalink
Merge branch '6/edge' into provide-config-db
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Nov 29, 2023
2 parents d8ca2dc + 0794ee0 commit 3f4b95f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/charms/mongodb/v0/config_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def _on_relation_changed(self, event) -> None:
event.defer()
return

# TODO: Follow up PR. Create an "operator" user for this mongos
# TODO: Follow up PR. Add a user for mongos once it has been started
self.charm.unit_peer_data["mongos_initialised"] = json.dumps(True)
self.charm.unit.status = ActiveStatus()
Expand Down
10 changes: 6 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,9 @@ def check_relation_broken_or_scale_down(self, event: RelationDepartedEvent) -> N
Relation departed and relation broken events occur during scaling down or during relation
removal, only relation departed events have access to metadata to determine which case.
"""
self.set_scaling_down(event)
scaling_down = self.set_scaling_down(event)

if self.is_scaling_down(event.relation.id):
if scaling_down:
logger.info(
"Scaling down the application, no need to process removed relation in broken hook."
)
Expand All @@ -1334,12 +1334,14 @@ def has_departed_run(self, rel_id: int) -> bool:
rel_departed_key = self._generate_relation_departed_key(rel_id)
return rel_departed_key in self.unit_peer_data

def set_scaling_down(self, event: RelationDepartedEvent) -> None:
def set_scaling_down(self, event: RelationDepartedEvent) -> bool:
"""Sets whether or not the current unit is scaling down."""
# check if relation departed is due to current unit being removed. (i.e. scaling down the
# application.)
rel_departed_key = self._generate_relation_departed_key(event.relation.id)
self.unit_peer_data[rel_departed_key] = json.dumps(event.departing_unit == self.unit)
scaling_down = json.dumps(event.departing_unit == self.unit)
self.unit_peer_data[rel_departed_key] = scaling_down
return scaling_down

@staticmethod
def _generate_relation_departed_key(rel_id: int) -> str:
Expand Down

0 comments on commit 3f4b95f

Please sign in to comment.