Skip to content

Commit

Permalink
send correct hosts for mongos k8s (#477)
Browse files Browse the repository at this point in the history
## Issue
1. Mongos K8s handles hosts in a very unique way compared to other
charms since it supports external connections
2. port information is not shared directly to clients (it is shared
instead in the URI)

## Solution
Update the way mongos k8s handles hosts for client relations
Remove port update
  • Loading branch information
MiaAltieri authored Sep 5, 2024
1 parent 4238861 commit e932849
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/charms/mongodb/v1/mongodb_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@

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

logger = logging.getLogger(__name__)
REL_NAME = "database"
MONGOS_RELATIONS = "cluster"
MONGOS_CLIENT_RELATIONS = "mongos_proxy"
EXTERNAL_CONNECTIVITY_TAG = "external-node-connectivity"

# We expect the MongoDB container to use the default ports

Expand Down Expand Up @@ -303,7 +302,7 @@ def _get_config(self, username: str, password: Optional[str]) -> MongoConfigurat
if self.charm.is_role(Config.Role.MONGOS):
mongo_args["port"] = Config.MONGOS_PORT
if self.substrate == Config.Substrate.K8S:
mongo_args["port"] = self.charm.get_mongos_port()
mongo_args["hosts"] = self.charm.get_mongos_hosts_for_client()
else:
mongo_args["replset"] = self.charm.app.name

Expand Down

0 comments on commit e932849

Please sign in to comment.