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

cannot start pgAdmin container with external database for pgAdmin user settings #7556

Closed
aremund opened this issue Jun 7, 2024 · 6 comments
Assignees
Milestone

Comments

@aremund
Copy link

aremund commented Jun 7, 2024

Describe the bug

I configured pgAdmin to use PostgreSQL instead of SQLite for user settings. Now, it cannot start up anymore.

To Reproduce

Steps to reproduce the behavior:

  1. create database pgadmindb
  2. create schema pgadmin
  3. deploy pgAdmin with the following deployment.yaml file
kind: Deployment
apiVersion: apps/v1
metadata:
  name: pgadmin
spec:
  selector:
   matchLabels:
    app: pgadmin
  replicas: 1
  template:
    metadata:
      labels:
        app: pgadmin
    spec:
      containers:
      - name: pgadmin4
        image: dpage/pgadmin4:8.8
        imagePullPolicy: IfNotPresent
        env:
        - name: PGADMIN_DEFAULT_EMAIL
          value: test@test.com
        - name: PGADMIN_DEFAULT_PASSWORD
          value: testsecret
        - name: PGADMIN_CONFIG_CONFIG_DATABASE_URI
          value: "'postgresql://pgadmin:secret@db-host:5432/pgadmindb?options=-csearch_path=pgadmin'"

Expected behavior

pgAdmin should successfully create the tables in the empty database and then start.

Error message

On the database pgadmindb

2024-06-07 19:28:14.142 CEST [2133648] pgadmin@pgadmindb ERROR:  relation "version" does not exist at character 75
2024-06-07 19:28:14.142 CEST [2133648] pgadmin@pgadmindb STATEMENT:  SELECT version.name AS version_name, version.value AS version_value
        FROM version
        WHERE version.name = $1::VARCHAR
         LIMIT $2::INTEGER
2024-06-07 19:28:14.550 CEST [2133648] pgadmin@pgadmindb LOG:  could not receive data from client: Connection reset by peer

In the Container-Log:

2024-06-07 17:27:42,133: INFO	pgadmin:	########################################################
2024-06-07 17:27:42,133: INFO	pgadmin:	Starting pgAdmin 4 v8.8...
2024-06-07 17:27:42,133: INFO	pgadmin:	########################################################
2024-06-07 17:27:42,133: DEBUG	pgadmin:	Python syspath: ['/pgadmin4', '/venv/bin', '/pgadmin4', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/venv/lib/python3.12/site-packages', '/usr/lib/python3.12/site-packages']
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

[2024-06-07 17:27:42 +0000] [90] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/venv/lib/python3.12/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/venv/lib/python3.12/site-packages/gunicorn/workers/gthread.py", line 95, in init_process
    super().init_process()
  File "/venv/lib/python3.12/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/venv/lib/python3.12/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
                ^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
                    ^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
           ^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/pgadmin4/run_pgadmin.py", line 4, in <module>
    from pgAdmin4 import app
  File "/pgadmin4/pgAdmin4.py", line 103, in <module>
    app = create_app()
          ^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/__init__.py", line 471, in create_app
    run_migration_for_others()
  File "/pgadmin4/pgadmin/__init__.py", line 456, in run_migration_for_others
    db_upgrade(app)
  File "/pgadmin4/pgadmin/setup/db_upgrade.py", line 25, in db_upgrade
    flask_migrate.upgrade(migration_folder)
  File "/venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 111, in wrapped
    f(*args, **kwargs)
  File "/venv/lib/python3.12/site-packages/flask_migrate/__init__.py", line 200, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/venv/lib/python3.12/site-packages/alembic/command.py", line 403, in upgrade
    script.run_env()
  File "/venv/lib/python3.12/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/setup/../../migrations/env.py", line 95, in <module>
    run_migrations_online()
  File "/pgadmin4/pgadmin/setup/../../migrations/env.py", line 87, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/venv/lib/python3.12/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/venv/lib/python3.12/site-packages/alembic/runtime/migration.py", line 627, in run_migrations
    step.migration_fn(**kw)
  File "/pgadmin4/migrations/versions/fdc58d9bd449_.py", line 38, in upgrade
    email, password = user_info()
                      ^^^^^^^^^^^
  File "/pgadmin4/pgadmin/setup/user_info.py", line 75, in user_info
    email, p1 = user_info_server()
                ^^^^^^^^^^^^^^^^^^
  File "/pgadmin4/pgadmin/setup/user_info.py", line 52, in user_info_server
    email = input(ENTER_EMAIL_ADDRESS)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
EOFError: EOF when reading a line
[2024-06-07 17:27:42 +0000] [90] [INFO] Worker exiting (pid: 90)
[2024-06-07 17:27:42 +0000] [1] [ERROR] Worker (pid:90) exited with code 3
[2024-06-07 17:27:42 +0000] [1] [ERROR] Shutting down: Master
[2024-06-07 17:27:42 +0000] [1] [ERROR] Reason: Worker failed to boot.
Email address: 
@aremund aremund added the Bug label Jun 7, 2024
@yogeshmahajan-1903
Copy link
Contributor

yogeshmahajan-1903 commented Jun 10, 2024

@aremund
Are you updating(specifically from 8.7 to 8.8) existing pgadmin app or doing fresh install? Are using secrets to provide PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD?

@aremund
Copy link
Author

aremund commented Jun 10, 2024

@yogeshmahajan-1903 I wanted to migrate to an external database for our existing installation (8.8) and added the PGADMIN_CONFIG_CONFIG_DATABASE_URI for our existing Installation.
Since this did not work, I tried it with a new installation and reported the ticket based on a new installation.
Yes, I use a secret for PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD.

@yogeshmahajan-1903
Copy link
Contributor

@aremund
Can you please check you secrets, I am doubting error is because empty secrets. Or May be just try directly passing PGADMIN_DEFAULT_EMAIL, PGADMIN_DEFAULT_PASSWORD just for test. I am not able to reproduce the issue , but I do not use secrets.

@mitchellkellett
Copy link

I had this issue too when I tried a fresh install of 8.8. I ended up installing 8.6. Then migrating to 8.8.

Mine didn't want to create anything, from memory it wanted to start the db migrations with an update to preferences.

@sdsys-ch
Copy link

I ran into the same issue today on a fresh install with 8.8. Environment was

Docker version 25.0.1, build 29cf629
Docker Compose version v2.24.2

Environment via docker compose env_file: .env.pgadmin statement:

PGADMIN_DEFAULT_EMAIL=--redacted--
PGADMIN_DEFAULT_PASSWORD=--redacted--
PGADMIN_DISABLE_POSTFIX=True
PGADMIN_CONFIG_APP_NAME="'... PGAdmin'"
PGADMIN_CONFIG_LANGUAGES="{'en': 'English', 'de': 'German', 'fr': 'French'}"
PGADMIN_CONFIG_DEFAULT_SERVER_PORT=80
PGADMIN_CONFIG_LOGIN_BANNER="'...'"
PGADMIN_CONFIG_DEBUG=False
PGADMIN_CONFIG_CONFIG_DATABASE_URI="'postgresql://pgadm_usr:--redacted--@db_srv:5432/pgadmin'"
PGADMIN_CONFIG_MAIL_SERVER="'...'"
PGADMIN_CONFIG_MAIL_PORT=587
PGADMIN_CONFIG_MAIL_SSL=False
PGADMIN_CONFIG_MAIL_TLS=True
PGADMIN_CONFIG_MAIL_USERNAME="'...'"
PGADMIN_CONFIG_MAIL_PASSWORD="'...'"
PGADMIN_CONFIG_SECURITY_EMAIL_SENDER="'...'"
PGADMIN_CONFIG_SESSION_EXPIRATION_TIME=5

Workaround by @mitchellkellett did the trick here as well. Thanks @mitchellkellett !

@pravesh-sharma
Copy link
Contributor

Issue fixed. Verified on docker snapshot image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants