openedx / tutor-contrib-aspects

The Open Analytics Reference System - Tutor plugin
Apache License 2.0
9 stars 12 forks source link

PyMongo 4.4.0 causes openedx to crash #891

Open CodeWithEmad opened 2 weeks ago

CodeWithEmad commented 2 weeks ago

We know that aspects v1.0.2 will use "platform-plugin-aspects==v0.9.7" and "edx-event-routing-backends==v9.2.1" and will add them in openedx-dockerfile-post-python-requirements patch

https://github.com/openedx/tutor-contrib-aspects/blob/306fe4467d86f3eb0e85495d55eecee963abe3e5/tutoraspects/patches/openedx-dockerfile-post-python-requirements#L1-L5

After installing aspects==1.0.2, weirdly, pymongo v4.4.0 will install and it causes a crash in lms and cms.

*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "lms/wsgi.py", line 25, in <module>
    modulestore()
  File "/openedx/edx-platform/xmodule/modulestore/django.py", line 331, in modulestore
    contentstore(),
  File "/openedx/edx-platform/xmodule/contentstore/django.py", line 29, in contentstore
    _CONTENTSTORE[name] = class_(**options)
  File "/openedx/edx-platform/xmodule/contentstore/mongo.py", line 44, in __init__
    mongo_db = connect_to_mongodb(
  File "/openedx/edx-platform/xmodule/mongo_utils.py", line 72, in connect_to_mongodb
    mongo_conn.authenticate(user, password, source=auth_source)
  File "/openedx/venv/lib/python3.8/site-packages/pymongo/collection.py", line 3217, in __call__
    raise TypeError(
TypeError: '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.

I'm fully aware that in the requirements of edx-event-routing-backends==v9.2.1 and event-tracking==2.3.2, pymongo 3.13.0 is specified.

https://github.com/openedx/event-routing-backends/blob/980b2aa264261430c5b8dfaeea70c02d44e5e08a/requirements/base.txt#L148

You can reproduce this by installing "edx-event-routing-backends==v9.2.1" in a new environment.

root@pubnito-nightly:/tmp/aspects# virtualenv -p python3 .venv
root@pubnito-nightly:/tmp/aspects# source .venv/bin/activate
(.venv) root@pubnito-nightly:/tmp/aspects# pip install "edx-event-routing-backends==v9.2.1"
(.venv) root@pubnito-nightly:/tmp/aspects# pip freeze | grep pymongo
pymongo==4.4.0

I see that event-tracking==2.4.1 is installed instead of 2.3.2 which makes it more vague.

(.venv) root@pubnito-nightly:/tmp/aspects# pip freeze | grep event-track
event-tracking==2.4.1

also, here is the pipdeptree for pymongo

(.venv) root@pubnito-nightly:/tmp/aspects# pipdeptree --reverse --packages pymongo
pymongo==4.4.0
├── edx-opaque-keys==2.10.0 [requires: pymongo]
│   ├── edx-ccx-keys==1.3.0 [requires: edx-opaque-keys>=2.0.0]
│   │   └── openedx-events==9.11.0 [requires: edx-ccx-keys]
│   │       └── event-tracking==2.4.1 [requires: openedx-events>=9.5.1]
│   │           └── edx-event-routing-backends==9.2.1 [requires: event-tracking>=2.3.2]
│   └── openedx-events==9.11.0 [requires: edx-opaque-keys]
│       └── event-tracking==2.4.1 [requires: openedx-events>=9.5.1]
│           └── edx-event-routing-backends==9.2.1 [requires: event-tracking>=2.3.2]
└── event-tracking==2.4.1 [requires: pymongo>=4.0.0,<4.4.1]
    └── edx-event-routing-backends==9.2.1 [requires: event-tracking>=2.3.2]
vahid75 commented 2 weeks ago

Yee the problem is with the event-routing-backends/requirements/constraints.txt that uses event-tracking>=2.3.2 . By this way pip will automatically install the latest event-tracking package which is 2.4.1 now. the problem is the difference between 2.4.1 & 2.4.0 which they upgraded the pymongo package from 3.13.0 to 4.4.0. I will create a PR on event-routing-backends project and put the link here.

bmtcril commented 1 week ago

I think the edx-lint fix is probably the best one until the edx-platform changes lance. Other projects are going to also pick up this change otherwise, and better to have one place to update later.