Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-3499] prevent shards from recieving backup actions + integrating on the s3 interface #357

Merged
merged 24 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
basic backups work
MiaAltieri committed Feb 7, 2024
commit b2962ed96d4e72694bcac4ab2ac6b6c86cd4fa2e
9 changes: 9 additions & 0 deletions lib/charms/mongodb/v0/mongodb.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ class MongoDBConfiguration:
roles: Set[str]
tls_external: bool
tls_internal: bool
standalone: bool = False

@property
def uri(self):
@@ -66,6 +67,14 @@ def uri(self):
auth_source = ""
if self.database != "admin":
auth_source = "&authSource=admin"

if self.standalone:
return (
f"mongodb://{quote_plus(self.username)}:"
f"{quote_plus(self.password)}@"
f"localhost:27017/?authSource=admin"
)

return (
f"mongodb://{quote_plus(self.username)}:"
f"{quote_plus(self.password)}@"
4 changes: 0 additions & 4 deletions lib/charms/mongodb/v1/shards_interface.py
Original file line number Diff line number Diff line change
@@ -181,10 +181,6 @@ def _on_relation_event(self, event):
logger.info("Adding/Removing shards not present in cluster.")
self.add_shards(departed_relation_id)
self.remove_shards(departed_relation_id)
# pbm has bug where when shard configuration is updated the config for pbm is removed
# pbm agent should be restarted when the cluster config is changed.

# self.charm._connect_pbm_agent()
except NotDrainedError:
# it is necessary to removeShard multiple times for the shard to be removed.
logger.info(
Binary file added percona-release_latest.generic_all.deb
Binary file not shown.
7 changes: 5 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
@@ -225,7 +225,9 @@ def monitor_config(self) -> MongoDBConfiguration:
def backup_config(self) -> MongoDBConfiguration:
"""Generates a MongoDBConfiguration object for backup."""
self._check_or_set_user_password(BackupUser)
return self._get_mongodb_config_for_user(BackupUser, BackupUser.get_hosts())
return self._get_mongodb_config_for_user(
BackupUser, BackupUser.get_hosts(), standalone=True
)

@property
def unit_peer_data(self) -> Dict:
@@ -773,7 +775,7 @@ def _get_mongos_config_for_user(
)

def _get_mongodb_config_for_user(
self, user: MongoDBUser, hosts: Set[str]
self, user: MongoDBUser, hosts: Set[str], standalone: bool = False
) -> MongoDBConfiguration:
external_ca, _ = self.tls.get_tls_files(UNIT_SCOPE)
internal_ca, _ = self.tls.get_tls_files(APP_SCOPE)
@@ -787,6 +789,7 @@ def _get_mongodb_config_for_user(
roles=user.get_roles(),
tls_external=external_ca is not None,
tls_internal=internal_ca is not None,
standalone=standalone,
)

def _get_user_or_fail_event(self, event: ActionEvent, default_username: str) -> Optional[str]:
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ class Config:
MONGODB_SNAP_DATA_DIR = "/var/snap/charmed-mongodb/current"
MONGOD_CONF_DIR = f"{MONGODB_SNAP_DATA_DIR}/etc/mongod"
MONGOD_CONF_FILE_PATH = f"{MONGOD_CONF_DIR}/mongod.conf"
SNAP_PACKAGES = [("charmed-mongodb", "6/edge", 93)]
SNAP_PACKAGES = [("charmed-mongodb", "6/edge/new-pbm-test-0", 107)]

# Keep these alphabetically sorted
class Actions: