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

Running a dev shell does not stop conflicting local containers #1193

Open
kdmccormick opened this issue Jan 31, 2025 · 0 comments
Open

Running a dev shell does not stop conflicting local containers #1193

kdmccormick opened this issue Jan 31, 2025 · 0 comments

Comments

@kdmccormick
Copy link
Collaborator

kdmccormick commented Jan 31, 2025

(Or vice versa)

Bug description

Dev and local containers should not be run simultaneously (this is a known constraint of Tutor, not a bug). A couple years ago we ensured that tutor dev start automatically stops any running local containers. However, tutor dev run ... does not stop local containers.

The converse of this is also a problem (running local containers does not stop dev, etc.).

This regularly manifests for me when I am switching back and forth between local and dev container shells to see how management commands work differently between development and production settings. The commands will run fine in one mode (whichever I started first), but then will fail in the other second mode, because the latter mode's MySQL container will fail to start.

How to reproduce

(venv-tutor) ~/openedx/edx-platform 🍀 tutor local run lms bash
docker compose -f /home/kyle/tutor-root/env/local/docker-compose.yml -f /home/kyle/tutor-root/env/local/docker-compose.prod.yml --project-name tutor_main_local run --rm lms bash
[+] Creating 6/6
 ✔ Container tutor_main_local-mysql-1        Created                                                                                                                                                                                                                               0.0s 
 ✔ Container tutor_main_local-smtp-1         Created                                                                                                                                                                                                                               0.0s 
 ✔ Container tutor_main_local-permissions-1  Created                                                                                                                                                                                                                               0.0s 
 ✔ Container tutor_main_local-meilisearch-1  Created                                                                                                                                                                                                                               0.0s 
 ✔ Container tutor_main_local-redis-1        Created                                                                                                                                                                                                                               0.0s 
 ✔ Container tutor_main_local-mongodb-1      Created                                                                                                                                                                                                                               0.0s 
[+] Running 6/6
 ✔ Container tutor_main_local-mysql-1        Started                                                                                                                                                                                                                               0.3s 
 ✔ Container tutor_main_local-smtp-1         Started                                                                                                                                                                                                                               0.2s 
 ✔ Container tutor_main_local-permissions-1  Started                                                                                                                                                                                                                               0.2s 
 ✔ Container tutor_main_local-redis-1        Started                                                                                                                                                                                                                               0.3s 
 ✔ Container tutor_main_local-meilisearch-1  Started                                                                                                                                                                                                                               0.3s 
 ✔ Container tutor_main_local-mongodb-1      Started                                                                                                                                                                                                                               0.2s 
app@3fb6b062cdd6:~/edx-platform$ exit
exit
(venv-tutor) ~/openedx/edx-platform 🍀 tutor local status
docker compose -f /home/kyle/tutor-root/env/local/docker-compose.yml -f /home/kyle/tutor-root/env/local/docker-compose.prod.yml --project-name tutor_main_local ps
NAME                             IMAGE                                    COMMAND                  SERVICE       CREATED       STATUS         PORTS
tutor_main_local-meilisearch-1   docker.io/getmeili/meilisearch:v1.8.4    "tini -- /bin/sh -c …"   meilisearch   13 days ago   Up 3 seconds   7700/tcp
tutor_main_local-mongodb-1       docker.io/mongo:7.0.7                    "docker-entrypoint.s…"   mongodb       7 weeks ago   Up 4 seconds   27017/tcp
tutor_main_local-mysql-1         docker.io/mysql:8.4.0                    "docker-entrypoint.s…"   mysql         7 weeks ago   Up 4 seconds   3306/tcp, 33060/tcp
tutor_main_local-redis-1         docker.io/redis:7.2.4                    "docker-entrypoint.s…"   redis         7 weeks ago   Up 3 seconds   6379/tcp
tutor_main_local-smtp-1          docker.io/devture/exim-relay:4.96-r1-0   "/sbin/tini -- exim …"   smtp          7 weeks ago   Up 4 seconds   8025/tcp
(venv-tutor) ~/openedx/edx-platform 🍀 tutor dev run lms bash
docker compose -f /home/kyle/tutor-root/env/local/docker-compose.yml -f /home/kyle/tutor-root/env/dev/docker-compose.yml --project-name tutor_main_dev run --rm lms bash
[+] Creating 6/6
 ✔ Container tutor_main_dev-smtp-1         Created                                                                                                                                                                                                                                 0.0s 
 ✔ Container tutor_main_dev-mysql-1        Created                                                                                                                                                                                                                                 0.0s 
 ✔ Container tutor_main_dev-permissions-1  Created                                                                                                                                                                                                                                 0.0s 
 ✔ Container tutor_main_dev-meilisearch-1  Created                                                                                                                                                                                                                                 0.0s 
 ✔ Container tutor_main_dev-redis-1        Created                                                                                                                                                                                                                                 0.0s 
 ✔ Container tutor_main_dev-mongodb-1      Created                                                                                                                                                                                                                                 0.0s 
[+] Running 6/6
 ✔ Container tutor_main_dev-permissions-1  Started                                                                                                                                                                                                                                 0.2s 
 ✔ Container tutor_main_dev-smtp-1         Started                                                                                                                                                                                                                                 0.2s 
 ✔ Container tutor_main_dev-mysql-1        Started                                                                                                                                                                                                                                 0.3s 
 ✔ Container tutor_main_dev-mongodb-1      Started                                                                                                                                                                                                                                 0.3s 
 ✔ Container tutor_main_dev-redis-1        Started                                                                                                                                                                                                                                 0.3s 
 ✔ Container tutor_main_dev-meilisearch-1  Started                                                                                                                                                                                                                                 0.3s 
app@cdaaed793916:~/edx-platform$ ./manage.py lms migrate
2025-01-31 14:45:17,501 WARNING 13 [py.warnings] [user None] [ip None] warnings.py:110 - /openedx/venv/lib/python3.11/site-packages/fs/__init__.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__("pkg_resources").declare_namespace(__name__)

2025-01-31 14:45:17,527 WARNING 13 [py.warnings] [user None] [ip None] warnings.py:110 - /openedx/venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2846: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)

2025-01-31 14:45:17,546 WARNING 13 [py.warnings] [user None] [ip None] warnings.py:110 - /openedx/venv/lib/python3.11/site-packages/fs/__init__.py:4: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  __import__("pkg_resources").declare_namespace(__name__)

2025-01-31 14:45:17,547 WARNING 13 [py.warnings] [user None] [ip None] warnings.py:110 - /openedx/venv/lib/python3.11/site-packages/fs/opener/__init__.py:6: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs.opener')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  __import__("pkg_resources").declare_namespace(__name__)
/
2025-01-31 14:45:17,548 WARNING 13 [py.warnings] [user None] [ip None] warnings.py:110 - /openedx/venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2331: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('fs')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(parent)

Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 289, in ensure_connection
    self.connect()
  File "/openedx/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 270, in connect
    self.connection = self.get_new_connection(conn_params)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 247, in get_new_connection
    connection = Database.connect(**conn_params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/__init__.py", line 121, in Connect
    return Connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 200, in __init__
    super().__init__(*args, **kwargs2)
MySQLdb.OperationalError: (2003, "Can't connect to MySQL server on 'mysql:3306' (111)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/openedx/edx-platform/./manage.py", line 106, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  ....
  [snipped]
  ....
  File "/openedx/venv/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 247, in get_new_connection
    connection = Database.connect(**conn_params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/__init__.py", line 121, in Connect
    return Connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/MySQLdb/connections.py", line 200, in __init__
    super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 'mysql:3306' (111)")
app@cdaaed793916:~/edx-platform$ 

Environment
Xubuntu 22.04, but I don't think that matters

@DawoudSheraz DawoudSheraz moved this from Pending Triage to Backlog in Tutor project management Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant