-
Notifications
You must be signed in to change notification settings - Fork 20
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
feat: support mongodb+srv urls #10
feat: support mongodb+srv urls #10
Conversation
bd4a562
to
a5aaf8e
Compare
7fa0df9
to
f233551
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keithgg looks good from my side!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain to me: why do we need to introduce new variables for the forum, but not for other apps, such as the LMS/CMS?
The MongoDB URL that I have actually is in this form:
I found that the query parameters weren't being parsed by the The python version of the driver included in the LMS/CMS functions in the expected manner and is able to parse the query parameters. |
So in theory we should be able to infer If yes, I propose that we do just that, to avoid the introduction of extra settings that duplicate values from elsewhere. From the user's perspective, it does not make much sense to have to update both We should thus write in templates something like:
For that the If this sounds confusing we can certainly have a synchronous conversation to clarify everything. |
If the ssl parameter does not need to be added to the mongodb+srv:// url, then how does the LMS/CMS mongodb client know that it should be using SSL? |
We patch it in our plugin. |
OK, so it would make sense to add a global I was sure that we had already discussed elsewhere adding the So what I did is that I opened a PR where I cherry-picked the commit; at the time the Forum app was part of the Tutor core, so I had to remove quite a few bits. Here's the PR: overhangio/tutor#741 @keithgg can you please review? Once the upstream PR is merged you will be able to use the |
@regisb Thank you! I'm happy with that approach and I don't mind approving the PR as it improves on the status quo. However, it only partially solves the problem here. I've needed to change at least these values from the defaults in the past (not for
For my current use case, I'll able to configure Atlas style clusters, but not Digital Ocean-style clusters. |
Right, this is an issue that was already discussed in that older PR: overhangio/tutor#415 (comment) Let me try to summarize:
Am I right so far? Could you please explain why item 4 is a problem? How do these providers declare the replicaset/authSource parameters? If it's the only reasonable option we'll add the |
I would prefer this as there currently isn't a way to configure those settings "out of the box" with
Yes.
It's a problem to me, because the UX is funky. Users will need be cognizant that some parameters need to be in the URL, but not all (like the Someone new to this will need to read ALL the documentation to configure their cluster. This imaginary person, will need to know that for Anyway, I'd rather improve the status quo than do nothing at all. Do you prefer:
|
Thanks for all the explanations Keith, I appreciate it. Your arguments are convincing and I think that option 1 is best. I'll add the two settings to my upstream PR. Can you please update your PR to make use of the new settings? |
This change builds upon a previously proposed PR: #437 There was another long conversation about this topic here: overhangio/tutor-forum#10 (comment) We could have supported the MongoDB auth/replica set/ssl parameters as part of the MongoDB host URI, but then this URI is not supported in the forum plugin, which uses an old version of the mongoid client. We were hoping that the client would have been upgraded by now, but it's not been upgraded for a long time. The changes introduced here are 100% backward-compatible. The forum plugin will have to be updated to take into account the new parameters.
Thank you @regisb. If I don't get to it today, I'll make the changes Monday first thing. |
tutorforum/templates/forum/build/forum/bin/docker-entrypoint.sh
Outdated
Show resolved
Hide resolved
This change builds upon a previously proposed PR: #437 There was another long conversation about this topic here: overhangio/tutor-forum#10 (comment) We could have supported the MongoDB auth/replica set/ssl parameters as part of the MongoDB host URI, but then this URI is not supported in the forum plugin, which uses an old version of the mongoid client. We were hoping that the client would have been upgraded by now, but it's not been upgraded for a long time. The changes introduced here are 100% backward-compatible. The forum plugin will have to be updated to take into account the new parameters.
189090c
to
d9d232f
Compare
@regisb I've made the requested changes. I tested with the built-in MongoDB container and an Atlas style cluster. Please review when you get a moment. |
This change builds upon a previously proposed PR: #437 There was another long conversation about this topic here: overhangio/tutor-forum#10 (comment) We could have supported the MongoDB auth/replica set/ssl parameters as part of the MongoDB host URI, but then this URI is not supported in the forum plugin, which uses an old version of the mongoid client. We were hoping that the client would have been upgraded by now, but it's not been upgraded for a long time. The changes introduced here are 100% backward-compatible. The forum plugin will have to be updated to take into account the new parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker-entrypoint.sh script is failing according to my local installation test.
tutorforum/templates/forum/build/forum/bin/docker-entrypoint.sh
Outdated
Show resolved
Hide resolved
d9d232f
to
67b639c
Compare
This change builds upon a previously proposed PR: #437 There was another long conversation about this topic here: overhangio/tutor-forum#10 (comment) We could have supported the MongoDB auth/replica set/ssl parameters as part of the MongoDB host URI, but then this URI is not supported in the forum plugin, which uses an old version of the mongoid client. We were hoping that the client would have been upgraded by now, but it's not been upgraded for a long time. The changes introduced here are 100% backward-compatible. The forum plugin will have to be updated to take into account the new parameters.
I couldn't get to work with these kind of setting, I error I got, is that host can't be defined, the host url started with "mongodb+srv", secondaly I am not entrily sure about the username/password in the URL. My understanding is that mongoid which is used by cs_commens_serivce expect certain ENV variable, but then you are using them on |
@ghassanmas looks like you need the host in the form I hadn't considered that, as the URLs I get are generated via terraform. We can document this and anyone that needs the username and password to be separate in the future can do a PR. What do you think? |
Leaving the I am first trying to run tutor to use external Mongodb url, but even the LMS fails with the following error:
My config.yml has the following
Also tried without using
Both settings didn't work for the I think before testing for the forum, I would want just to try to do it only for the It seems to be that we have tutor setting for monogo, that is expected to be consumed by different client, each support it's own way to parse the url depending on the version of the mongo client So we have two mongo clients:
For those different type of clients, which typically they consume configuration from tutor, we are trying to support different form of auth-url, what I don't completely understand yet is:
|
@ghassanmas to get it working on the LMS/CMS you just need to add For example: OPENEDX_EXTRA_PIP_REQUIREMENTS:
- dnspython
Yes. We're trying to re-use the configuration that was done for the LMS so that it can apply to the |
I see, anyway can this wait for Ruby 3 update openedx/cs_comments_service#392 becuse it's suppsoe to be merged soon and then we might avoide duplicate work in case that change conflict with ruby client though from quick look it doesn't seem related. But just as to do one thing a time. Secondaly, would you consider another path of upgrading the ruby client in cs_commens_service instead of having the plugin handle that? |
It doesn't change what this PR is trying to do. Which is add some config options. I'd rather merge this and make further changes down the line once that is merged (if required). What do you think?
I'm not sure I understand. Do you mind elaborating? |
I meant to say that instead of us trying to change tutor-forum to support different use cases of mongourl, we might instead udpate monogo client in cs_comments_service to accept simliar configuration to the LMS/CMS. Thus making configuration more consistant. On the other hand, I couldn't yet test this, the free atlas connection I got is based on Mongo V5, while the default version of Mongo in Open edX/tutor is V4. Lastly I am still not confident about this, given that I couldn't test as mentioned above, the best I can do right now is to ensure that this change doesn't break the typical way tutor uses mongo, i.e. mongo is a local service managed by docker-compose. |
Sure, but I'm assuming those changes won't be backported, which means users of the Olive release won't be able to deploy the forum without forking this plugin.
I can provide test credentials for you. Would you like me to? |
@keithgg that would be great, I will try now to ping you on Open edX slack. |
@ghassanmas this is an issue that we discussed before (though I'm not sure where). The mongoid client has been outdated for years, so it's hopeless to wait for an upgrade from the cs_comments_service maintainers. |
Noted. So after long testing I found that in my case where I have free atlass cluster, I needed to define important query params, other the LMS connection won't work, those are So if I understand the situation correctly, this needs to strip querey params from |
@ghassanmas what do you need in order to merge this PR? If I understand you correctly, you would like to: Parse the
|
1- For the username and password issue link works fine for the LMS/CMS and the forum in the case where both username and password exist in the URL/host. I didn't test for another way around (when username and password are set outside the URL). 2- Now the problem with this PR is that it expects the URL host MongoDB to not include or to have query params, So again through my testing, I had to include extra query params for it to work with the LMS, where in my case the host URL is
Regarding your last point
If you referring to the forum, it ran okay without setting any query params, however for the LMS the URL/HOST had to have both Also a reflection point through my investigation/testing, it turns out the LMS/CMS is using a deprecated version of pymongo 3.* where the latest is 4.* and here we are dealing with an even more legacy version of a mongo client for ruby. And on top of all that, we would want the same MongoDB host URL to work for the LMS/CMS and the forum out of the box. Lastly from my end and based on my observation I can suggest two ways to resolve this:
I wonder what @regisb thinks about the two methods above, or if there are other alternatives. I am personally okay with any, but again I am not an expert when it comes to mongo configuration. |
@ghassanmas Okay cool. So how about we add a For the LMS, if the same value is supplied to
Agreed that those need to be updated, but any upgrades are out of scope for this PR. |
@ghassanmas @regisb any feedback on the above? |
@keithgg so I guess in summary we have two ways to handle this
I don't have strong feeling to either approach, so I am happy with either, I guess we would just update Readme/docs to reflect the decision we take. Checking with @regisb do you have any preference for any? |
@keithgg First of all I'm very sorry that it is taking so long to merge your PR. We should work to reach an agreement as soon as possible. Frankly, it's difficult for me to understand all the finer points of the conversation here. I propose that we have a synchronous meeting to discuss the best solution. In general, I would rather that we try to avoid the following:
Instead, I would prefer if:
These items are personal preferences, not hard requirements, so we can discuss them. @ghassanmas can you organize a meeting next week for the three of us? |
@regisb sounds good, I have created this link so you both can the time that works best for you. I will put my time last, since I am currently traveling it's hard for me to choose right, should be able by the end of this week though. Here is the link: https://whenisgood.net/arejtw3-mongo-forum |
Good call on the sync meeting @regisb thanks for organising @ghassanmas. I've added my available times. Looking forward to it! |
Great, Let's meet on Wednesday 10:00am UTC. That shall work for everyone |
Recap of today's meeting:
Thanks to you both for your work and your patience! |
a022197
to
69b3673
Compare
69b3673
to
b645d58
Compare
@ghassanmas @regisb I've made the documentation changes as discussed. Please take a look and let me know if I should make any changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! We're getting there ;) Thanks again Keith!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience @keithgg, it looks good to me
🥳 🎉 🎈 |
Description
At the moment the plugin does not support some options to deploy when the MongoDB url is of the newer mongodb+srv format.
This PR makes the necessary changes to make this work.
Three new config options are added:
MONGODB_USE_SSL
: String value "false" or "true" to toggle SSL connections.MONGODB_AUTH_SOURCE
: The MongoDB db to use for authentication details.MONGODB_AUTH_MECH
: The authentication mechanism used to communicate with MongoDB. Defaults to""
. Since themongodb+srv://
urls can contain the username/password for authentication, this flag didn't get set in thedocker-entrypoint.sh
script. We should allow the user to specify this if needed.adminSource
and whether to enableSSL
MONGO_HOST
is of themongodb+srv
format, don't check that the server is up, because it's quite tricky.Testing instructions
Check that existing configurations will work unchanged
pip install git+https://github.com/open-craft/tutor-forum@keith/checklist-fixes
# install the plugintutor plugins enable forum
tutor config save
tutor build images forum
tutor local quickstart
Should work without any issues.
Check that mongodb+srv urls works
Add to your
config.yml
Then run the above steps again. When deploying the forum you will see the output to confirmed it's parsed correctly.
The forum deployment will fail obviously, because the details above are invalid. I can provide access to a MongoDB server if needed.