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: replica set error from pymongo 3.10 -> 3.12 upgrade #699

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

ormsbee
Copy link
Contributor

@ormsbee ormsbee commented Jun 30, 2022

The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
tutor dev quickstart:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance.

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

(Actually, going to hold on this because while it did get me past the migration, I should wait until I have a fully functioning local tutor dev env.)

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

Okay, now I'm past the initial migration, but I'm running into:

Traceback (most recent call last):
  File "./manage.py", line 102, in <module>
    startup = importlib.import_module(edx_args.startup)
  File "/opt/pyenv/versions/3.8.12/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/openedx/edx-platform/lms/startup.py", line 10, in <module>
    settings.INSTALLED_APPS  # pylint: disable=pointless-statement
  File "/openedx/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/openedx/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/openedx/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/opt/pyenv/versions/3.8.12/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/openedx/edx-platform/lms/envs/tutor/development.py", line 3, in <module>
    from lms.envs.devstack import *
  File "/openedx/edx-platform/lms/envs/devstack.py", line 334, in <module>
    CONTENTSTORE['DOC_STORE_CONFIG']['replicaSet'] = None
TypeError: 'NoneType' object is not subscriptable

I must confess that I don't really grok how Tutor handles config yet, so this might take me a little while.

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

Ah, okay, so tutor's development.py would set the MongoDB parameters with the templated value altered in this PR, but that file imports everything from devstack.py and that's where CONTENTSTORE['DOC_STORE_CONFIG']['replicaSet'] = None is getting set when there's no value for CONTENTSTORE['DOC_STORE_CONFIG'], and thus explosion.

But then, why didn't that change break devstack too?

@regisb
Copy link
Contributor

regisb commented Jun 30, 2022

The error you are facing is because Tutor sets CONTENTSTORE: null in lms.yml:


{% include "apps/openedx/config/partials/auth.yml" %}

Here's the original commit which introduced this null value: f32eb08
I'm not sure whether you can remove this entry from auth.yml. Maybe you can try?

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

Thanks @regisb!

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

@regisb: That worked! Though I don't really understand what taking that out might break...?

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

I'll add it to the PR anyhow.

@ormsbee ormsbee force-pushed the fix_mongo_replica branch 2 times, most recently from 600d014 to 90f2233 Compare June 30, 2022 16:17
@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

@regisb: Does this look okay to you?

@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

Ah, forgot the CHANGELOG policy in this repo. Going to add that now...

@ormsbee ormsbee force-pushed the fix_mongo_replica branch from 90f2233 to 64c03cf Compare June 30, 2022 16:28
@ormsbee
Copy link
Contributor Author

ormsbee commented Jun 30, 2022

Okay, now I think it's ready for review. 😄 Thank you for your patience as I stumble through my first Tutor contribution.

@aht007
Copy link

aht007 commented Jul 1, 2022

Ah, okay, so tutor's development.py would set the MongoDB parameters with the templated value altered in this PR, but that file imports everything from devstack.py and that's where CONTENTSTORE['DOC_STORE_CONFIG']['replicaSet'] = None is getting set when there's no value for CONTENTSTORE['DOC_STORE_CONFIG'], and thus explosion.

But then, why didn't that change break devstack too?

This change didn't cause any issues with devstack because in the pymongo upgrade PR we already tackled this in configuration
I didn't know if it would cause any issue with tutor else I would have already given a heads up.

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -1,7 +1,6 @@
SECRET_KEY: "{{ OPENEDX_SECRET_KEY }}"
AWS_ACCESS_KEY_ID: "{{ OPENEDX_AWS_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "{{ OPENEDX_AWS_SECRET_ACCESS_KEY }}"
CONTENTSTORE: null
Copy link
Contributor

Choose a reason for hiding this comment

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

The pymongo dependency for edx-platform was updated (3.10.1 to 3.12.3)
in openedx/edx-platform#30569

This caused the following error when running the edx-platform database
migration split_modulestore_django.0002_data_migration as part of
`tutor dev quickstart`:

  pymongo.errors.ServerSelectionTimeoutError: client is configured to
  connect to a replica set named '' but this node belongs to a set named
  'None', Timeout: 30s, Topology Description: <TopologyDescription id:
  62bdbaf182687350acf1aeec, topology_type: Single, servers:
  [<ServerDescription ('mongodb', 27017) server_type: Unknown, rtt:
   None, error=ConfigurationError("client is configured to connect to a
   replica set named '' but this node belongs to a set named 'None'")>]>

This commit explicitly sets replicaSet to None to indicate that it's a
standalone MongoDB instance. I also had to remove the CONTENTSTORE entry
from auth.yml because edx-platform's devstack.py assumes it has a
non-null value (set in common.py), and devstack.py executes before
tutor's development.py can set this replicaSet value.
@ormsbee ormsbee force-pushed the fix_mongo_replica branch from 51e54eb to a89d545 Compare July 5, 2022 14:26
Copy link
Contributor

@regisb regisb left a comment

Choose a reason for hiding this comment

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

It's cool to merge your first PR here Dave :)

@regisb regisb merged commit 6ac1c0d into overhangio:nightly Jul 5, 2022
@kdmccormick kdmccormick mentioned this pull request Aug 15, 2022
@ormsbee ormsbee deleted the fix_mongo_replica branch April 8, 2023 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants