elastic/opbeans-node

Database initialization fails : SCRAM authentication requires libpq version 10 or above

jlvoiseux opened this issue · 5 comments

Description

When cloning the project as is and building the docker container, the database cannot be initialised as SCRAM authentication fails on my M1 Mac.

Screenshots

image
image

To Reproduce (Tested on a M1 Mac and a x86_64 Ubuntu)

  • Clone the repo locally
  • Build the docker container using docker-compose up
  • The container loadPgData exits with the following error : psql: SCRAM authentication requires libpq version 10 or above
  • An error is displayed when accessing the app running locally.

Possible solutions

The container use to initialize the database (LoadPgData) uses node:12, which is based on Debian Stretch. The default version of postgres-client is then 9.6, which does not satisfy the requirements for SCRAM authentication with Postgres 14.

I have tested two solutions locally that allow the project to work "out of the box" again :

  • Force the Postgres version in the Docker-compose file to 13.5 in order to fetch the most recent version supporting SCRAM authentication from libpq < 10.
  • Use a Node image based on a more recent Debian version, such as node:12-bullseye. The default postgresql-client downloaded is then postgresql-client-13, which satisfies the requirements for SCRAM auth with Postgres 14.

Thanks!

To Reproduce (Tested on a M1 Mac and a x86_64 Ubuntu)
...

I could not repro (the app comes up and works) locally on my first try. I am on an x86 Mac. Could that be the difference?

Or it could be that I have old built Docker images lying around that are being used here? I don't think so, because my local node:12 still gives me postgres-client 9.6:

% docker run --rm -ti node:12 /bin/bash
root@16eb8d84acc3:/# apt-get update
...
root@16eb8d84acc3:/# apt-get install postgresql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  distro-info-data libpq-dev libpq5 lsb-release postgresql-client-9.6 postgresql-client-common
Suggested packages:
  postgresql-doc-9.6 lsb postgresql-9.6
The following NEW packages will be installed:
  distro-info-data lsb-release postgresql-client postgresql-client-9.6 postgresql-client-common
The following packages will be upgraded:
  libpq-dev libpq5
2 upgraded, 5 newly installed, 0 to remove and 41 not upgraded.
Need to get 1823 kB of archives.
After this operation, 6103 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Possible solutions

Would moving to node:16 work? From https://hub.docker.com/_/node that looks like it based on Debian buster, which defaults to:

buster (oldstable) (database): front-end programs for PostgreSQL (supported version)
11+200+deb10u4: all
also provided by: postgresql-client-11 

However, moving to ...-bullseye to get on the current Debian stable sounds fine to me. @jlvoiseux Did you want to start a PR?

Or it could be that I have old built Docker images lying around that are being used here?

Oh, I have an older postgres:latest that is using Postgres 13.4:

% docker run --rm -ti postgres:latest /bin/bash
root@5c635cb4e461:/# psql --version
psql (PostgreSQL) 13.4 (Debian 13.4-1.pgdg100+1)

Now I get an error from ./db/setup.sh but a different one:

$ docker-compose up
...
loadPgData_1     |
loadPgData_1     | > opbeans-node@1.0.0 db-setup /app
loadPgData_1     | > ./db/setup.sh
loadPgData_1     |
loadPgData_1     | psql: could not translate host name "postgres" to address: Name or service not known
loadPgData_1     | npm ERR! code ELIFECYCLE
loadPgData_1     | npm ERR! errno 2
loadPgData_1     | npm ERR! opbeans-node@1.0.0 db-setup: `./db/setup.sh`
...


% docker-compose --version
docker-compose version 1.29.2, build 5becea4c

I'm not sure what is going on there.

I can reproduce now after starting somewhat cleaner:

% docker-compose down --volumes    # to remove old pre-existing volumes
...

% docker-compose up -V
...
loadPgData_1     | psql: SCRAM authentication requires libpq version 10 or above
...

Thank you for your feedback ! I just tried to use node:16, but it seems to introduce dependency errors :

loadPgData_1 | npm ERR!
loadPgData_1 | npm ERR! Could not resolve dependency:
loadPgData_1 | npm ERR! peer webpack@"^4.0.0" from css-loader@1.0.1
loadPgData_1 | npm ERR! node_modules/css-loader
loadPgData_1 | npm ERR! css-loader@"^1.0.1" from the root project
loadPgData_1 | npm ERR!

I will start a PR with the move to Debian Bullseye.