diff --git a/src/charm.py b/src/charm.py index 6719d8d6e..e9295a94d 100755 --- a/src/charm.py +++ b/src/charm.py @@ -242,11 +242,17 @@ def db_initialised(self) -> bool: @property def role(self) -> str: """Returns role of MongoDB deployment.""" - if "role" not in self.app_peer_data and self.unit.is_leader(): + if ( + "role" not in self.app_peer_data + and self.unit.is_leader() + and self.model.config["role"] + ): self.app_peer_data["role"] = self.model.config["role"] + # app data bag isn't set until function completes + return self.model.config["role"] else: # if leader hasn't set the role yet, use the one set by model - self.model.config["role"] + return self.model.config["role"] return self.app_peer_data.get("role") @@ -563,7 +569,7 @@ def _on_get_primary_action(self, event: ActionEvent): def _on_get_password(self, event: ActionEvent) -> None: """Returns the password for the user as an action response.""" username = self._get_user_or_fail_event( - event, default_username=OperatorUser.get_username() + event, default_username=f"OperatorUser.get_username()" ) if not username: return @@ -590,7 +596,7 @@ def _on_set_password(self, event: ActionEvent) -> None: return username = self._get_user_or_fail_event( - event, default_username=OperatorUser.get_username() + event, default_username=f"OperatorUser.get_username()" ) if not username: return