Repository navigation
mongo_future_return: MongoDb Connection string support - #48371
Conversation
There was a problem hiding this comment.
would it make sense to use salt.utils.versions.LooseVersion instead of float(), to be uniform with other version checks throughout salt's codebase?
that's valid for both mongo_future_return.py and mongo_returner.py
There was a problem hiding this comment.
I can change it to the LooseVersion.
I did not want to change code not related to the URI feature but I could imagine installing salt 2018 requires lots of up to date python modules so it could be the time to remove support for pymongo < 2.3
In that case port, host and other configs could be removed and only connection string would be supported ( you can easily put all previously used options into connection string format)
If you and other salt contributors think it is OK, I can make the changes.
There was a problem hiding this comment.
I'm not that familiar with mongodb and I don't know the users' existing code-base, so I can't recommend anything. Maybe is okay to deprecate it (a sudden removal seems.. sudden).
I thought it's a low-hanging-fruit and seems among the last places where salt has a custom version compare. I think it can easily be done independent of this change though.
I'm not an official reviewer, so it's not in my power to approve things.
LE: I did look in their documentation and they support both host:port and URI when creating a client:
http://api.mongodb.com/python/current/tutorial.html#making-a-connection-with-mongoclient
However, their c++11 driver only works with URI
What if instead of having a warning and having the URI taking precedence over the host:port config of the client, you just error out so the user can fix his configuration not to contain both?
There was a problem hiding this comment.
Good idea, so all in all:
- depreciate host and port configuration ( but still support it)
- error on both uri and host
- any comments on removing 2.3 support anyone?
There was a problem hiding this comment.
Yes, lets use LooseVersion.
We shouldn't remove support for older versions if we can help it. And I would say we shouldn't remove support for older configurations when it isn't absolutely necessary.
gtmanfred
left a comment
There was a problem hiding this comment.
Just a couple changes.
Thanks!
Daniel
There was a problem hiding this comment.
Please provide an example of the uri format.
Thanks,
Daniel
There was a problem hiding this comment.
I have updated doc, and changed LooseVersion in mongo_future_return and mongo_return. I did some more extra handling so that only uri or host can be specified in the config file.
Tested with pymongo 3.6 and 2.3
There was a problem hiding this comment.
Yes, lets use LooseVersion.
We shouldn't remove support for older versions if we can help it. And I would say we shouldn't remove support for older configurations when it isn't absolutely necessary.
There was a problem hiding this comment.
If you wouldn't mind, it would be great to move all these other version comparisons to using LooseVersion as well.
What does this PR do?
PR adds MongoDB connection string support (URI), what enables using replica set and other connection options.
Those features are already supported in pymongo so this PR only adds URI config and passes it to pymongo.
What issues does this PR fix or reference?
Tests written?
No
Commits signed with GPG?
No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.