repository-service-tuf/repository-service-tuf-worker

Bug: RSTUF db migration fails with certain environment variables

kairoaraujo opened this issue · 1 comments

What happened?

The current RSTUF Worker allows certain SQL Server configurations using the environment variables:

Single entry in plain text

      - RSTUF_SQL_SERVER=postgresql://postgres:secret@postgres:5432

Multiple entry splitting in multiple environment variables

      - RSTUF_SQL_SERVER=postgres:5432
      - RSTUF_SQL_USER=postgres
      - RSTUF_SQL_PASSWORD=secret

Multiple entry splitting in multiple environment variables using secrets for password

      - RSTUF_SQL_SERVER=postgres:5432
      - RSTUF_SQL_USER=postgres
      - RSTUF_SQL_PASSWORD=/run/secrets/SECRETS_POSTGRES_PASSWORD
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 637, in connect
repository-service-tuf-worker_1  |     return dialect.connect(*cargs, **cparams)
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 616, in connect
repository-service-tuf-worker_1  |     return self.loaded_dbapi.connect(*cargs, **cparams)
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
repository-service-tuf-worker_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
repository-service-tuf-worker_1  | sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) fe_sendauth: no password supplied
repository-service-tuf-worker_1  | 
repository-service-tuf-worker_1  | (Background on this error at: https://sqlalche.me/e/20/e3q8)
repository-service-tuf-worker_1  | Failed to initiate the database
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 804, in engine_from_config
repository-service-tuf-worker_1  |     return create_engine(url, **options)
repository-service-tuf-worker_1  |   File "<string>", line 2, in create_engine
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 283, in warned
repository-service-tuf-worker_1  |     return fn(*args, **kwargs)  # type: ignore[no-any-return]
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 548, in create_engine
repository-service-tuf-worker_1  |     u = _url.make_url(url)
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/url.py", line 838, in make_url
repository-service-tuf-worker_1  |     return _parse_url(name_or_url)
repository-service-tuf-worker_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/url.py", line 898, in _parse_url
repository-service-tuf-worker_1  |     raise exc.ArgumentError(
repository-service-tuf-worker_1  | sqlalchemy.exc.ArgumentError: Could not parse SQLAlchemy URL from string 'postgres:5432'
repository-service-tuf-worker_1  | Failed to initiate the database

What steps did you take?

No response

What behavior did you expect?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

It crashes the containers. :(