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 5235] support external clients #32

Merged
merged 14 commits into from
Sep 27, 2024

Conversation

MiaAltieri
Copy link
Collaborator

@MiaAltieri MiaAltieri commented Aug 30, 2024

Issue

We support toggling of external connectivity, but we do not give clients external access

Solution

Support providing all clients an a URI that is reachable outside of K8s

Future PR

an additional PR should be made for providing ext clients with all available ext ports for their correct hosts.

This is currently not supported since URI handling in mongo.py/mongos.py/mongodb.py since they only take a single port as an argument

@MiaAltieri MiaAltieri changed the title Dpe 5235 support external clients [DPE 5235] support external clients Aug 30, 2024
lib/charms/mongodb/v0/set_status.py Outdated Show resolved Hide resolved
lib/charms/mongodb/v1/mongodb_provider.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from 0120a45 to 1fd1850 Compare September 2, 2024 17:39
Copy link

codecov bot commented Sep 2, 2024

Codecov Report

Attention: Patch coverage is 22.80702% with 44 lines in your changes missing coverage. Please review.

Project coverage is 45.70%. Comparing base (e4b8dae) to head (bf4e3bf).

Files with missing lines Patch % Lines
src/node_port.py 21.87% 25 Missing ⚠️
src/charm.py 24.00% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           6/edge      #32      +/-   ##
==========================================
- Coverage   48.57%   45.70%   -2.88%     
==========================================
  Files           4        4              
  Lines         492      547      +55     
==========================================
+ Hits          239      250      +11     
- Misses        253      297      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from 1fd1850 to 7110ca0 Compare September 3, 2024 06:59
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from 7110ca0 to bf4e3bf Compare September 3, 2024 15:38
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from a256dac to 25f2b05 Compare September 4, 2024 07:48
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from 21c6f00 to 53635c0 Compare September 4, 2024 08:32
src/charm.py Outdated Show resolved Hide resolved
src/node_port.py Outdated
@@ -154,4 +155,61 @@ def delete_unit_service(self) -> None:
else:
raise

@property
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

functions brought over and modified from MySQL Router, PGBouncer, Kafka. (they were all slightly different so I tried to converge them + make them work for mine)



@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy a sharded cluster."""
application_charm = await ops_test.build_charm("tests/integration/application/")
Copy link
Contributor

Choose a reason for hiding this comment

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

We should put this in a fixture like we're doing in mongodb vm

Copy link
Contributor

@Mehdi-Bendriss Mehdi-Bendriss left a comment

Choose a reason for hiding this comment

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

Thanks Mia, I have a couple of comments

lib/charms/mongos/v0/set_status.py Show resolved Hide resolved
src/node_port.py Show resolved Hide resolved
src/charm.py Outdated
for unit in self.peers_units:
hosts = set()
for unit in self.get_units():
unit_ip = self.node_port_manager.get_node_ip(unit.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not checking on unit_ip is None given it is the case on ApiError.status_code == 403, which will effectively add a host of the form None:port

We are also not handling exceptions of get_node_id / get_node_port. Is this intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are not checking on unit_ip is None given it is the case on ApiError.status_code == 403, which will effectively add a host of the form None:port

Good points Mehdi. This function should certainly be updated. We must make changes on VM side PR here

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the linked PR is not the right one on the topic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is - the changes you requested require that we raise and error here and then handle it in the provider side?

src/node_port.py Show resolved Hide resolved
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from ae54d7d to 194d872 Compare September 11, 2024 08:58
src/node_port.py Outdated Show resolved Hide resolved
src/charm.py Outdated Show resolved Hide resolved
@MiaAltieri MiaAltieri force-pushed the DPE-5235-support-external-clients branch from 945c449 to e109d49 Compare September 13, 2024 16:11
Note this only removes users that this application of Charmed MongoDB is responsible for
managing. It won't remove:
1. users created from other applications
2. users created from other mongos routers.
Copy link
Member

Choose a reason for hiding this comment

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

Is this lib shared between mongod and mongos?
I think we should clean up on mongod and mongos a bit differently.
We know the pattern of routers. We can additionally clean up users created by routers on Mongod when the router relation is gone.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for this - that behaviour exists in MongoDB VM charms, but not in K8s since routers handles the users differently I filed an issue here - @Mehdi-Bendriss and I will work to prioritise the issue and get it addressed

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.

4 participants