Skip to content

Commit

Permalink
[DPE-5236][DPE-5647][DPE-5645] update mongo* libs (#341)
Browse files Browse the repository at this point in the history
* charmcraft fetch lib

* update tests now that statuses are upated

* update tests to handle ops deprication message

* Add Neha's fix for password with subprocess

* generate client after removal
  • Loading branch information
MiaAltieri authored Oct 9, 2024
1 parent 9e06746 commit 7d8d0bf
Show file tree
Hide file tree
Showing 13 changed files with 1,250 additions and 368 deletions.
5 changes: 3 additions & 2 deletions lib/charms/mongodb/v0/config_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 12
LIBPATCH = 13


class ClusterProvider(Object):
Expand Down Expand Up @@ -318,7 +318,8 @@ def _on_relation_changed(self, event) -> None:
return

self.charm.status.set_and_share_status(ActiveStatus())
self.charm.mongos_intialised = True
if self.charm.unit.is_leader():
self.charm.mongos_initialised = True

def _on_relation_broken(self, event: RelationBrokenEvent) -> None:
# Only relation_deparated events can check if scaling down
Expand Down
10 changes: 8 additions & 2 deletions lib/charms/mongodb/v0/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NotReadyError(PyMongoError):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 1
LIBPATCH = 2

ADMIN_AUTH_SOURCE = "authSource=admin"
SYSTEM_DBS = ("admin", "local", "config")
Expand All @@ -40,6 +40,7 @@ class NotReadyError(PyMongoError):
{"role": "userAdminAnyDatabase", "db": "admin"},
{"role": "readWriteAnyDatabase", "db": "admin"},
{"role": "userAdmin", "db": "admin"},
{"role": "enableSharding", "db": "admin"},
],
"monitor": [
{"role": "explainRole", "db": "admin"},
Expand Down Expand Up @@ -127,7 +128,12 @@ def uri(self):

def supported_roles(config: MongoConfiguration):
"""Return the supported roles for the given configuration."""
return REGULAR_ROLES | {"default": [{"db": config.database, "role": "readWrite"}]}
return REGULAR_ROLES | {
"default": [
{"db": config.database, "role": "readWrite"},
{"db": config.database, "role": "enableSharding"},
]
}


class MongoConnection:
Expand Down
6 changes: 3 additions & 3 deletions lib/charms/mongodb/v0/set_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 4
LIBPATCH = 6

AUTH_FAILED_CODE = 18
UNAUTHORISED_CODE = 13
Expand Down Expand Up @@ -264,11 +264,11 @@ def get_cluster_mismatched_revision_status(self) -> Optional[StatusBase]:

if self.charm.is_role(Config.Role.SHARD):
config_server_revision = self.charm.version_checker.get_version_of_related_app(
self.get_config_server_name()
self.charm.get_config_server_name()
)
remote_local_identifier = (
"-locally built"
if self.charm.version_checker.is_local_charm(self.get_config_server_name())
if self.charm.version_checker.is_local_charm(self.charm.get_config_server_name())
else ""
)
return BlockedStatus(
Expand Down
Loading

0 comments on commit 7d8d0bf

Please sign in to comment.