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

[BUG] MongoDB ext_pillar fails #62083

Open
githubcdr opened this issue May 19, 2022 · 2 comments
Open

[BUG] MongoDB ext_pillar fails #62083

githubcdr opened this issue May 19, 2022 · 2 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage Pillar Regression The issue is a bug that breaks functionality known to work in previous releases.

Comments

@githubcdr
Copy link
Contributor

Description

Salt mongodb ext_pillar fails with following error, was working in previous version.

Failed to load ext_pillar mongo: 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.

Setup
Running saltstack/salt:3004.1 docker

Steps to Reproduce the behavior
configure mongodb pillar

Expected behavior
a working setup

Versions Report

/ # salt --versions
Salt Version:
          Salt: 3004.1

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.3
       libgit2: 1.1.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.17
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: 1.6.1
        Python: 3.7.13 (default, Mar 18 2022, 17:55:41)
  python-gnupg: 0.4.4
        PyYAML: 5.4.1
         PyZMQ: 18.0.1
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist: alpine 3.14.4
        locale: UTF-8
       machine: x86_64
       release: 5.17.6-arch1-1
        system: Linux
       version: Alpine Linux 3.14.4
@githubcdr githubcdr added Bug broken, incorrect, or confusing behavior needs-triage labels May 19, 2022
@githubcdr githubcdr changed the title [BUG] [BUG] MongoDB ext_pillar fails May 19, 2022
@OrangeDog OrangeDog added Regression The issue is a bug that breaks functionality known to work in previous releases. Pillar labels May 20, 2022
@githubcdr
Copy link
Contributor Author

githubcdr commented Jun 7, 2022

related: https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html#database-authenticate-and-database-logout-are-removed

workaround is to downgrade to pymongo 3.9

pip3 install pymongo==3.9

@ekacnet
Copy link

ekacnet commented Jun 25, 2023

The following patch is fixing the issue for 4.X while being compatible with 3.6 and above.

--- /root/mongodb.py    2023-06-24 23:57:26.994184917 -0700
+++ /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mongodb.py    2023-05-05 10:44:35.000000000 -0700
@@ -63,10 +63,11 @@
         authdb = database
 
     try:
+        if user and password:
+            conn = pymongo.MongoClient(host=host, port=port, user, password)
+        else:
+            conn = pymongo.MongoClient(host=host, port=port)
-        conn = pymongo.MongoClient(host=host, port=port)
         mdb = pymongo.database.Database(conn, database)
-        if user and password:
-            mdb.authenticate(user, password, source=authdb)
     except pymongo.errors.PyMongoError:
         log.error("Error connecting to database %s", database)
         return False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage Pillar Regression The issue is a bug that breaks functionality known to work in previous releases.
Projects
None yet
Development

No branches or pull requests

3 participants