Skip to content

Commit

Permalink
Apply Mehdi's suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mehdi Bendriss <[email protected]>
  • Loading branch information
MiaAltieri and Mehdi-Bendriss authored Mar 11, 2024
1 parent 117f413 commit 92230ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/charms/mongodb/v0/mongodb_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def _get_subject_name(self) -> str:
if self.charm.is_role(Config.Role.SHARD):
# until integrated with config-server use current app name as
# subject name
subject_name = self.charm.shard.get_config_server_name() or self.charm.app.name
return subject_name
return self.charm.shard.get_config_server_name() or self.charm.app.name

return self.charm.app.name
14 changes: 9 additions & 5 deletions lib/charms/mongodb/v1/shards_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,19 @@ def _handle_changed_secrets(self, event) -> None:
# FUTURE PR: if config-server does not have TLS enabled log a useful message and go into
# blocked in relation_changed and other status checks

def get_membership_auth_modes(self, event) -> Tuple:
def get_membership_auth_modes(self, event: RelationChangedEvent) -> Tuple[bool, bool]:
"""Returns the available authentication membership forms."""
key_file_contents = self.database_requires.fetch_relation_field(
event.relation.id, KEYFILE_KEY
)
tls_ca = self.database_requires.fetch_relation_field(event.relation.id, INT_TLS_CA_KEY)
return (key_file_contents is not None, tls_ca is not None)

def update_member_auth(self, event, membership_auth) -> None:
def update_member_auth(
self, event: RelationChangedEvent, membership_auth: Tuple[bool, bool]
) -> None:
"""Updates the shard to have the same membership auth as the config-server."""
(key_file_contents, cluster_tls_ca) = membership_auth
is_key_file_contents_auth, is_tls_auth = membership_auth
tls_integrated = self.charm.model.get_relation(Config.TLS.TLS_PEER_RELATION)

# Edge case: shard has TLS enabled before having connected to the config-server. For TLS in
Expand All @@ -596,7 +598,7 @@ def update_member_auth(self, event, membership_auth) -> None:
# Future PR - status updating for inconsistencies with TLS (i.e. shard has TLS but
# config-server does not and vice versa or CA-mismatch)

def get_cluster_passwords(self, event) -> Tuple:
def get_cluster_passwords(self, event: RelationChangedEvent) -> Tuple[Optional[str], Optional[str]]:
"""Retrieves shared cluster passwords."""
operator_password = self.database_requires.fetch_relation_field(
event.relation.id, OPERATOR_PASSWORD_KEY
Expand All @@ -606,7 +608,9 @@ def get_cluster_passwords(self, event) -> Tuple:
)
return (operator_password, backup_password)

def update_cluster_passwords(self, event, operator_password, backup_password):
def update_cluster_passwords(
self, event: RelationChangedEvent, operator_password: str, backup_password: str
) -> None:
"""Updates shared cluster passwords."""
try:
self.update_password(
Expand Down

0 comments on commit 92230ce

Please sign in to comment.