This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new d4dc73416a Remove the upper version bound on pymongo (#31189)
d4dc73416a is described below
commit d4dc73416a652a895ada6484d67879a1aad5f0bb
Author: Jon Shea <[email protected]>
AuthorDate: Thu May 11 06:30:53 2023 -0400
Remove the upper version bound on pymongo (#31189)
There was an upper version bound on pymongo of `<4.0.0` because versions
4.0.0+ removed the `ssl_cert_reqs` parameter from client connection
options. However, comparing the pymongo 3.7.0 docs
(https://pymongo.readthedocs.io/en/3.7.0/examples/tls.html#certificate-verification-policy)
to the 4.3.3 docs
(https://pymongo.readthedocs.io/en/4.3.3/examples/tls.html#certificate-verification-policy)
it seems that `ssl_cert_reqs` has been effectively renamed to
`tlsAllowInvalidCertificates`.
This PR removes upper version bound on pymongo, and adds a test to set
`tlsAllowInvalidCertificates` for pymongo 4.0.0 and later, while continuing
to use `ssl_cert_reqs` for earlier versions of pymongo.
---
airflow/providers/mongo/hooks/mongo.py | 7 ++++++-
airflow/providers/mongo/provider.yaml | 4 +---
docs/apache-airflow-providers-mongo/index.rst | 2 +-
generated/provider_dependencies.json | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/airflow/providers/mongo/hooks/mongo.py
b/airflow/providers/mongo/hooks/mongo.py
index a5e91bb4a7..b37a76dcf3 100644
--- a/airflow/providers/mongo/hooks/mongo.py
+++ b/airflow/providers/mongo/hooks/mongo.py
@@ -82,7 +82,12 @@ class MongoHook(BaseHook):
# If we are using SSL disable requiring certs from specific hostname
if options.get("ssl", False):
- options.update({"ssl_cert_reqs": CERT_NONE})
+ if pymongo.__version__ >= "4.0.0":
+ # In pymongo 4.0.0+ `tlsAllowInvalidCertificates=True`
+ # replaces `ssl_cert_reqs=CERT_NONE`
+ options.update({"tlsAllowInvalidCertificates": True})
+ else:
+ options.update({"ssl_cert_reqs": CERT_NONE})
self.client = MongoClient(self.uri, **options)
return self.client
diff --git a/airflow/providers/mongo/provider.yaml
b/airflow/providers/mongo/provider.yaml
index e34d68ed61..20a39adab7 100644
--- a/airflow/providers/mongo/provider.yaml
+++ b/airflow/providers/mongo/provider.yaml
@@ -39,9 +39,7 @@ versions:
dependencies:
- apache-airflow>=2.4.0
- dnspython>=1.13.0
- # pymongo 4.0.0 removes connection option `ssl_cert_reqs` which is used in
providers-mongo/2.2.0
- # TODO: Upgrade to pymongo 4.0.0+
- - pymongo>=3.6.0,<4.0.0
+ - pymongo>=3.6.0
integrations:
- integration-name: MongoDB
diff --git a/docs/apache-airflow-providers-mongo/index.rst
b/docs/apache-airflow-providers-mongo/index.rst
index 22493b33c4..db55c8639d 100644
--- a/docs/apache-airflow-providers-mongo/index.rst
+++ b/docs/apache-airflow-providers-mongo/index.rst
@@ -75,7 +75,7 @@ PIP package Version required
================== ==================
``apache-airflow`` ``>=2.3.0``
``dnspython`` ``>=1.13.0``
-``pymongo`` ``>=3.6.0,<4.0.0``
+``pymongo`` ``>=3.6.0``
================== ==================
.. include:: ../../airflow/providers/mongo/CHANGELOG.rst
diff --git a/generated/provider_dependencies.json
b/generated/provider_dependencies.json
index 1f1a8e1f5c..d576dc9078 100644
--- a/generated/provider_dependencies.json
+++ b/generated/provider_dependencies.json
@@ -522,7 +522,7 @@
"deps": [
"apache-airflow>=2.4.0",
"dnspython>=1.13.0",
- "pymongo>=3.6.0,<4.0.0"
+ "pymongo>=3.6.0"
],
"cross-providers-deps": []
},