GMOD / docker-apollo

:whale: Apollo 2.X Docker Image
GNU General Public License v3.0
10 stars 12 forks source link

PSQL Password auth fails for user "apollo" when different DB_USERNAME is supplied #43

Closed MoffMade closed 5 years ago

MoffMade commented 5 years ago

Starting the docker-apollo container using the environment flags WEBAPOLLO_DB_USERNAME and CHADO_DB_USERNAME set to 'postgres' instead of the default results in positive messages and connections to the databases at the beginning of the launch script but after Shiro is configured I get the following error, and several similar ones after.

SEVERE [localhost-startStop-2] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
 org.postgresql.util.PSQLException: FATAL: password authentication failed for user "apollo"

I also get a "Starting Tomcat servlet engine: tomcat8 failed!" message and some catalina INFO messages before Shiro.

Here are the environment variables being passed to the container via Dockerfile through Rancher.

"environment": {
    "CONTEXT_PATH": "/apollo-testing",
    "WEBAPOLLO_DB_HOST": "db.apollo-testing.rancher.internal",
    "WEBAPOLLO_DB_NAME": "postgres",
    "WEBAPOLLO_DB_USERNAME": "postgres",
    "WEBAPOLLO_DB_PASSWORD": REMOVED,   
    "CHADO_DB_HOST": "chado.apollo-testing.rancher.internal",
    "CHADO_DB_NAME": "postgres",
    "CHADO_DB_USERNAME": "postgres",
    "CHADO_DB_PASSWORD": REMOVED,
    "WEBAPOLLO_COMMON_DATA_DIRECTORY": "/opt/apollo/data/galaxy",
    "WEBAPOLLO_TRANSLATION_TABLE": "11",
},

This is a dump of the errors from startup to the end, if left alive the container just repeats the errors from the one quoted above. I removed much of the stacktrace for easier reading but I can provide it if needed. docker-apollo-startup-logs-short.txt

nathandunn commented 5 years ago

@MoffMade I don't know much about rancher, but I passed in variables via an environmental file and it seemed to work:

 sudo docker run -it -p 8080:8080 --env-file env.file -v /home/ubuntu/postgres_data:/var/b/postgresql -v /home/ubuntu/apollo_data:/data quay.io/gmod/docker-apollo:latest

where env-file is:

CONTEXT_PATH=/apollo-testing
WEBAPOLLO_DB_HOST=db.apollo-testing.rancher.internal
WEBAPOLLO_DB_NAME=postgres
WEBAPOLLO_DB_USERNAME=postgres
WEBAPOLLO_DB_PASSWORD=REMOVED
CHADO_DB_HOST=chado.apollo-testing.rancher.internal
CHADO_DB_NAME=postgres
CHADO_DB_USERNAME=postgres
CHADO_DB_PASSWORD=REMOVED
WEBAPOLLO_COMMON_DATA_DIRECTORY=/opt/apollo/data/galaxy
WEBAPOLLO_TRANSLATION_TABLE=11
sudo docker run -it -p 8080:8080 --env-file env.file -v /home/ubuntu/postgres_data:/var/lib/postgresql -v /home/ubuntu/apollo_data:/data quay.io/gmod/docker-apollo:latest
[ ok ] Starting PostgreSQL 9.6 database server: main.
WEBAPOLLO_HOST_FLAG: -h db.apollo-testing.rancher.internal
CHADO_HOST_FLAG: -h chado.apollo-testing.rancher.internal
Waiting for DB

Of course for me it hangs because it doesn't exist.

MoffMade commented 5 years ago

I get to that point, see these logs:

Starting PostgreSQL 9.6 database server: main.
WEBAPOLLO_HOST_FLAG: -h db.apollo-testing.rancher.internal
CHADO_HOST_FLAG: -h chado.apollo-testing.rancher.internal
Waiting for DB
db.apollo-testing.rancher.internal:5432 - accepting connections
Postgres is up, configuring database
Configuring Chado
Restarting tomcat with /var/lib/tomcat8
Starting Tomcat servlet engine: tomcat8 failed!
29-May-2019 19:54:38.505 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/share/tomcat8
29-May-2019 19:54:38.505 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/tmp/tomcat8-tomcat8-tmp
29-May-2019 19:54:38.505 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
29-May-2019 19:54:38.568 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
29-May-2019 19:54:38.580 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
29-May-2019 19:54:38.582 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 347 ms
29-May-2019 19:54:38.600 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
29-May-2019 19:54:38.601 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.14 (Debian)
29-May-2019 19:54:38.622 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /var/lib/tomcat8/webapps/.war
29-May-2019 19:54:38.629 WARNING [localhost-startStop-1] org.apache.catalina.core.StandardContext.setPath A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
29-May-2019 19:54:44.421 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
log4j:WARN No appenders could be found for logger (org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Configuring Shiro ...

Shiro Configured
29-May-2019 19:54:55.211 SEVERE [localhost-startStop-1] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
  org.postgresql.util.PSQLException: FATAL: password authentication failed for user "apollo"
...
...
...

It gets past checking the database availability but fails later with user "apollo" rather than the username "postgres" that was passed to it (and assuming was used for the original db check)

nathandunn commented 5 years ago

Oh, I see the problem now. I'll see if I can't reproduce it in order to find a fix.

MoffMade commented 5 years ago

I'm pulling the image from quay.io/gmod/docker-apollo:latest if that helps narrow things down.

nathandunn commented 5 years ago

Yeah, somehow the apollo-config.groovy doesn't seem to be pulling stuff out of the environment correctly. Trying to see why now.

nathandunn commented 5 years ago
nathandunn commented 5 years ago

After dump we get this on build:

WEBAPOLLO environment
WEBAPOLLO_VERSION 1bf62017418435811fb7ec7a5baac33b05513fdf

We run it this way:

 docker run  --env-file=env.list -v /opt/apollo/:/data -p 8888:8080 ddc9932da43f  

with this env file:

WEBAPOLLO_DB_USERNAME="hal"
WEBAPOLLO_DB_PASSWORD="superpass"
WEBAPOLLO_USE_CHADO="false"
WEBAPOLLO_DB_NAME="somedb"
nathandunn commented 5 years ago

Use this:

https://forums.docker.com/t/passing-environment-variables-to-a-docker-image-to-a-file-in-tomcat/59199

nathandunn commented 5 years ago

Have to create setenv.sh . .

nathandunn commented 5 years ago

@MoffMade I think this OR fixes it: https://github.com/GMOD/docker-apollo/pull/46

You can use this tag (yes, fix is twice): quay.io/gmod/docker-apollo:fix-fix-43

There are quite a few changes, but I think its better in a number of ways, but let me know.