troubleshoot - GradedJestRisk/cicd-training GitHub Wiki

Troubleshoot

Start container

docker run --name ptm-visualisation registry.gitlab.com/erpc-group/transverse/ptm/apps/ptm-visualisation

Get logs

Check why the application crashed

docker logs test --follow

DB unreachable

org.postgresql.util.PSQLException: Connection to db-ptm-integration:5497 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Get configuration

Extract jar

docker cp ptm-visualisation:/app/ptm-visualisation.jar /tmp/test.jar

Locate in application.yml the connection string :

  trace-datasource:
    url: jdbc:postgresql://db-ptm-integration:5497/integration_db
    username: integration
    password: integration
    driver-class-name: org.postgresql.Driver

Check database itself

docker logs --follow db-ptm-integration

Check configuration: connections are allowed from all IPs https://github.com/bitnami/containers/blob/main/bitnami/postgresql/16/debian-12/Dockerfile

grep listen_address /opt/bitnami/postgresql/conf/postgresql.conf
listen_addresses = '*'

Check from outside (host)

Works on port 5497

psql --dbname "host=db-ptm-integration port=5497 dbname=integration_db user=integration password=integration"

Check from application container

As the container crash, we cannot connect to it

Check network

docker network ls
docker network inspect infra_default

Start container (user 0 is root)

docker run --user 0 --tty --interactive --network=infra_default --name test registry.gitlab.com/erpc-group/transverse/ptm/apps/ptm-visualisation bash

Check we're on the same network

docker network inspect infra_default

Yes

Containers": {
            "18bc2685fc5bf92125a31c11b2fe3f0a8042127aeac664c7f4769c247992ff40": {
                "Name": "db-ptm-integration",
                "EndpointID": "f89aeb8e13f820c26d4f4986f0122b586cd8356927a1070c044a60e26826c244",
                "MacAddress": "02:42:ac:1c:00:02",
                "IPv4Address": "172.28.0.2/16",
                "IPv6Address": ""
            },
            "28d06112ae1251e8c4f72a2c58b6adb8abb3917a2d90bf199413b123e0945b33": {
                "Name": "test",
                "EndpointID": "5d35dee589961f4f16ed21c697daebe36cd2cb90a5e5b472fef278ac998e959f",
                "MacAddress": "02:42:ac:1c:00:05",
                "IPv4Address": "172.28.0.5/16",
                "IPv6Address": ""
            },

Checks database is reachable

apt install iputils-ping
ping db-ptm-integration

Install PG client

apt update
apt install postgresql-client

Then test if DB is reachable on 5432

psql postgresql://db-ptm-integration:5432
# Password for user root: 

Connect : OK

psql --dbname "host=db-ptm-integration port=5432 dbname=integration_db user=integration password=integration"

Then test if credentials are valid using configuration connection string

psql postgresql://db-ptm-integration:5497/integration_db

Does not work because of wrong port ! Works on 5432

psql postgresql://integration:integration@db-ptm-integration:5432/integration_db
psql postgresql://permissions:permissions@db-ptm-permissions:5432/permissions_db
⚠️ **GitHub.com Fallback** ⚠️