Page MenuHomePhabricator

Add dependencies for Postgresql to Kubernetes container
Closed, DeclinedPublic

Description

I am trying to start a Django server on Tool Labs and am running into an issue with the Postgresql libraries.

It was suggested to me that the container might not have access to the system package that is required to use psycopg2.

I am also still investigating if it a linking issue.

File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/models/options.py", line 214, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/utils.py", line 211, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/utils.py", line 115, in load_backend
    return import_module('%s.base' % backend_name)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 2, in <module>
    from django.db.backends.postgresql.base import \
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: libpq.so.5: cannot open shared object file: No such file or directory
unable to load app 0 (mountpoint='') (callable not found or import error)
mounting /data/project/commons-campaign-commander/www/python/src/app.py on /commons-campaign-commander
Traceback (most recent call last):
  File "/data/project/commons-campaign-commander/www/python/src/app.py", line 7, in <module>
    app = get_wsgi_application()
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/data/project/commons-campaign-commander/www/python/venv/lib/python3.4/site-packages/django/apps/registry.py", line 78, in populate
    raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Why not switch to a pure python postgres driver like https://pypi.python.org/pypi/py-postgresql or https://pypi.python.org/pypi/pg8000 ? Usage of postgres in tool labs is going to be a very uncommon thing. We have been attempting to keep the Docker images used for our Kubernetes deploy as small as possible.

bd808 triaged this task as Medium priority.Mar 26 2017, 6:50 PM

The postgis database backend of Django is based on psycopg2. Probably it would need to be re-implemented in py-postgresql. Not sure how much effort that would take. Will think about it or maybe look for another hosting solution.

bd808 changed the task status from Open to Stalled.Jun 7 2017, 12:53 AM

The postgis database backend of Django is based on psycopg2. Probably it would need to be re-implemented in py-postgresql. Not sure how much effort that would take. Will think about it or maybe look for another hosting solution.

@Tobias1984: Heja, any news? Asking as I don't like tasks to be stalled for years. :)

Unfortunately closing this Phabricator task as no further information has been provided.

@Tobias1984: After you have provided the information asked for and if this still happens, please set the status of this task back to "Open" via the Add Action...Change Status dropdown. Thanks!