Skip to content

patch(DPE-10361): Charm stabilization#354

Open
Gu1nness wants to merge 24 commits into
DPE-10362-ca-refactorfrom
DPE-10361-mongo-db-charm-stabilization-implementation
Open

patch(DPE-10361): Charm stabilization#354
Gu1nness wants to merge 24 commits into
DPE-10362-ca-refactorfrom
DPE-10361-mongo-db-charm-stabilization-implementation

Conversation

@Gu1nness

Copy link
Copy Markdown
Contributor

🏷️ Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling and CI
  • Dependencies upgrade or change
  • Chores / refactoring

📝 Description

This PR is mostly refactoring and cleanup.

  • Statuses recomputation after restart for a limited set of managers (mongos on mongos, shard on mongod)
  • Mongos config-changed handler optionally restarts.
  • Mongos config-changed has proper error handling.
  • Charm state properly sets the tls_enabled flag when we have the secrets && the certificate is on the file system.
  • TLS keyfile is removed from mongodb configuration objects (we don't do mtls)

🧪 Manual testing steps

1. juju deploy <my-app>
2. …

🔬 Automated testing steps

✅ Checklist

  • My code follows the code style of this project.
  • I have added or updated any relevant documentation.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Gu1nness Gu1nness changed the title feat(DPE-10361): Charm stabilization patch(DPE-10361): Charm stabilization Jun 15, 2026
@Gu1nness Gu1nness changed the base branch from 8/edge to DPE-10362-ca-refactor June 15, 2026 14:27
@Gu1nness Gu1nness force-pushed the DPE-10361-mongo-db-charm-stabilization-implementation branch from 527d885 to 74df9c1 Compare June 15, 2026 14:28
@Gu1nness Gu1nness force-pushed the DPE-10361-mongo-db-charm-stabilization-implementation branch from aba580c to 2464508 Compare June 17, 2026 09:48
Comment thread single_kernel_mongo/events/sharding.py
Comment thread single_kernel_mongo/events/sharding.py
config-server to add the shard to the cluster.
"""
# By setting the status we ensure that the former statuses of this component are removed.
self.state.statuses.set(ShardStatuses.ACTIVE_IDLE.value, scope="unit", component=self.name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in the reconcile_shard_after_restart?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because that would not cover the case where the restart is triggered by TLS manager (which is not this callback but the other one.
Overall this is more a final cleanup than anything (after everything is integrated, let's go back to the proper status.
I'm not happy about this one however, maybe we should find a better way to do taht.

Comment thread single_kernel_mongo/events/sharding.py

def _handle_changed_secrets(self, event: SecretChangedEvent):
"""SecretChanged event handler, which is used to propagate the updated passwords."""
try:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PBM restart also raises a WorkloadServiceError which is not handled here

self.update_pbm_certificate_in_trust_store()
if self.update_pbm_certificate_in_trust_store():
try:
# after updating the password of the backup user, restart pbm with correct password

@patriciareinoso patriciareinoso Jun 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the restart after the backup user changed happens in sync_cluster_passwords, this one happens if the PBM certs changed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, would it be worth it to find a way to just restart PBM once here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth it, but I'm careful: if we remove the automated restart from the synchronize cluster passwords, then it means that everytime we use that method, we have to take care to restart afterwards.
TBH I think this is probably the safest solution.

the restart after the backup user changed happens in WorkloadServiceError

I think you mean "ends up in WorkloadServiceError" ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a mistake in what I wrote. I already corrected it.
I meant that the comment "after updating the password of the backup user, restart pbm with correct password" is not correct. Here we are restarting because the PBM certs changed, not because of the password update

except MissingCredentialsError:
return False

def mongodb_config_for_user(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any use of mongodb_config_for_user that includes tls_external_ca

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet (and hopefully won't happen, but I'd rather keep it for consistency (have the same interface as mongos_config_for_user)

Comment thread single_kernel_mongo/managers/mongos_operator.py

@patriciareinoso patriciareinoso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Neha!
just a couple of nits

Comment thread single_kernel_mongo/utils/mongo_config.py
@patriciareinoso

patriciareinoso commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

I went trough it again

the only thing that seems misplaced to me is the active status in the handle_pbm function which you already explained.

Also I would rather not add an unused parameter to mongodb_config_for_user I find it misleading.

Other than that all good

Also manual testing toogling TLS went really smooth. Last week I was not able to enable client TLS without seing an error. So thank you

@Gu1nness

Copy link
Copy Markdown
Contributor Author

@patriciareinoso You're right for the active status.
Let's recompute everything in that handler.

@Gu1nness Gu1nness requested a review from patriciareinoso June 19, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants