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

Fix mongo connections #63053

Merged
merged 5 commits into from
Nov 18, 2022
Merged

Fix mongo connections #63053

merged 5 commits into from
Nov 18, 2022

Conversation

genaumann
Copy link
Contributor

What does this PR do?

What issues does this PR fix or reference?

Add:

  • mongo.uri configuration in ext_pillar

Fix:

  • remove depr. pymongo authenticate function in mongo ext_pillar and returner

Previous Behavior

Mongo ext_pillar was not useable, because the pymongo authenticate function is deprecated.

New Behavior

Now you are able to connect to mongo with uri. And the mongo ext_pillar module is usable.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Don't know how to write tests for salt - sorry 👎

Commits signed with GPG?

No

@genaumann genaumann requested a review from a team as a code owner November 9, 2022 23:19
@genaumann genaumann requested review from MKLeb and removed request for a team November 9, 2022 23:19
@garethgreenaway garethgreenaway added Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases needs-changelog-file labels Nov 10, 2022
@@ -178,17 +178,15 @@ def _get_conn(ret):
mdb = conn.get_database()
else:
if PYMONGO_VERSION > _LooseVersion("2.3"):
conn = pymongo.MongoClient(host, port)
conn = pymongo.MongoClient(host, port, username=user, password=password)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the username and password for the above client declarations? Line 177 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, otherwise pymongo throws the following exception:

pymongo.errors.OperationFailure: command insert requires authentication, full error: {'ok': 0.0, 'errmsg': 'command insert requires authentication', 'code': 13, 'codeName': 'Unauthorized'}

@MKLeb
Copy link
Contributor

MKLeb commented Nov 10, 2022

Hi @genaumann, and thanks for the contribution. If you want, we have a few ways for you to learn how to write tests for salt. There is also some concise documentation on the process here. Otherwise, we will have to wait for someone else to pick up the tests here, which can take a lot of time.

@genaumann
Copy link
Contributor Author

Hi @MKLeb, I tried my best to write a testcase for returner and ext_pillar.
The tests are not detailed and perhaps should be extended.
I created an issue and a changelog for this fix.

@cmcmarrow
Copy link
Contributor

#62083

@cmcmarrow
Copy link
Contributor

@genaumann we should probably add a test where we don't expect it to fail. This link will help you fix your pre-commit test https://pre-commit.com/.

@genaumann
Copy link
Contributor Author

@cmcmarrow pre-commit pipeline doesn’t fail anymore

@MKLeb
Copy link
Contributor

MKLeb commented Nov 16, 2022

re-run pr-centos-7-x86_64-py3-tcp-pytest
re-run pr-centosstream-9-x86_64-py3-pytest

@Ch3LL Ch3LL merged commit 1b719d7 into saltstack:master Nov 18, 2022
@welcome
Copy link

welcome bot commented Nov 18, 2022

Congratulations on your first PR being merged! 🎉

@genaumann genaumann deleted the fix_mongo_connections branch November 18, 2022 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-changelog-file Needs-Testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants