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

Dockerfile: Install Ubuntu package python3-mysqldb #39

Conversation

quatauta
Copy link
Contributor

@quatauta quatauta commented Apr 24, 2024

In Dockerfile, install Ubuntu package python3-mysqldb.

Running changelog in Kubernetes causes ModuleNotFoundError: No module named 'MySQLdb'.

Installing Ubuntu package python3-mysqldb provides the required module.

kubectl -n changelog logs deployment/changelog
Starting gunicorn with 2 workers, listening on 0.0.0.0:5000
[2024-04-24 09:22:50 +0000] [7] [INFO] Starting gunicorn 22.0.0
[2024-04-24 09:22:50 +0000] [7] [INFO] Listening at: http://0.0.0.0:5000 (7)
[2024-04-24 09:22:50 +0000] [7] [INFO] Using worker: eventlet
[2024-04-24 09:22:50 +0000] [8] [INFO] Booting worker with pid: 8
[2024-04-24 09:22:50 +0000] [9] [INFO] Booting worker with pid: 9
[2024-04-24 09:22:50 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/geventlet.py", line 143, in init_process
    super().init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/changelog/application.py", line 27, in <module>
    db = SQLAlchemy(app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 278, in __init__
    self.init_app(app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 374, in init_app
    engines[key] = self._make_engine(key, options, app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 665, in _make_engine
    return sa.engine_from_config(options, prefix="")
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/create.py", line 803, in engine_from_config
    return create_engine(url, **options)
  File "<string>", line 2, in create_engine
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/create.py", line 601, in create_engine
    dbapi = dbapi_meth(**dbapi_args)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 152, in import_dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
[2024-04-24 09:22:50 +0000] [8] [INFO] Worker exiting (pid: 8)
[...]

@quatauta quatauta self-assigned this Apr 24, 2024
@quatauta quatauta requested a review from a team April 24, 2024 09:28
@quatauta quatauta changed the title [SRE-4731] Dockerfile: Install Ubuntu package python3-mysqldb Dockerfile: Install Ubuntu package python3-mysqldb Apr 24, 2024
In [Dockerfile](./Dockerfile), install Ubuntu package [`python3-mysqldb`](https://packages.ubuntu.com/jammy/python3-mysqldb).

Running `changelog` in Kubernetes causes `ModuleNotFoundError: No module named 'MySQLdb'`.

Installing Ubuntu package [`python3-mysqldb`](https://packages.ubuntu.com/jammy/python3-mysqldb) provides the required module.

```console
❯ kubectl -n changelog logs deployment/changelog
Starting gunicorn with 2 workers, listening on 0.0.0.0:5000
[2024-04-24 09:22:50 +0000] [7] [INFO] Starting gunicorn 22.0.0
[2024-04-24 09:22:50 +0000] [7] [INFO] Listening at: http://0.0.0.0:5000 (7)
[2024-04-24 09:22:50 +0000] [7] [INFO] Using worker: eventlet
[2024-04-24 09:22:50 +0000] [8] [INFO] Booting worker with pid: 8
[2024-04-24 09:22:50 +0000] [9] [INFO] Booting worker with pid: 9
[2024-04-24 09:22:50 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/geventlet.py", line 143, in init_process
    super().init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/changelog/application.py", line 27, in <module>
    db = SQLAlchemy(app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 278, in __init__
    self.init_app(app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 374, in init_app
    engines[key] = self._make_engine(key, options, app)
  File "/usr/local/lib/python3.10/dist-packages/flask_sqlalchemy/extension.py", line 665, in _make_engine
    return sa.engine_from_config(options, prefix="")
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/create.py", line 803, in engine_from_config
    return create_engine(url, **options)
  File "<string>", line 2, in create_engine
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/create.py", line 601, in create_engine
    dbapi = dbapi_meth(**dbapi_args)
  File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 152, in import_dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
[2024-04-24 09:22:50 +0000] [8] [INFO] Worker exiting (pid: 8)
[...]
```
@quatauta quatauta force-pushed the feature/SRE-4731-dockerfile-ubuntu-package-python3-mysqldb branch from e052a20 to 5d3bac7 Compare April 24, 2024 09:50
@quatauta quatauta closed this Apr 24, 2024
@quatauta quatauta deleted the feature/SRE-4731-dockerfile-ubuntu-package-python3-mysqldb branch April 24, 2024 09: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.

1 participant