Skip to content

CreateUpdateDB Job can not not connect to Database which is up #2

@ashjacksonwf1

Description

@ashjacksonwf1

With the create-update-db job in the helm chart, I can not find any combination of parameters that results in a successful connection to the Postgres database, even though psql commands running in the shell of the container itself can connect to the database. The server version is 15.3 (OnGres 15.3-build-6.30)

Helm

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: zabbix
  namespace: dpt-zabbix
spec:
  releaseName: zabbix
  targetNamespace: dpt-zabbix
  # interval: ${flux_helm_chart_reconciliation_period}
  interval: 1h
  chart:
    spec:
      chart: zabbix
      version: 7.0.12
      # interval: ${flux_helm_chart_reconciliation_period}
      interval: 1h
      sourceRef:
        kind: HelmRepository
        name: zabbix-community
  values:
    zabbixImageTag: ubuntu-7.2.11
    postgresAccess:
      existingSecretName: credentials-db-zabbix
      secretHostKey: Host
      secretUserKey: username
      secretPortKey: Port
      secretPasswordKey: password
      secretDBKey: Database
      secretSchemaKey: ""
    zabbixServer:
      enabled: true
      zabbixServerHA:
        enabled: true
        dbCreateUpgradeJob:
          image:
            tagSuffix: "20250802113243"
      replicaCount: 3
      podAntiAffinity: true
      resources: {}
      service:
        type: LoadBalancer
        port: 10051
      persistence:
        enabled: false
    zabbixWeb:
      enabled: true
      replicaCount: 3
      resources: {}
      service:
        type: ClusterIP
        port: 8080
      ingress:
        enabled: false
    zabbixAgent:
      enabled: true
      resources: {}
    postgresql:
      enabled: false

Debug output from Job

zabbix-create-upgrade-db-snn5w:~$ /usr/bin/docker-entrypoint.sh init_and_upgrade_db 
+ : false
+ ZABBIX_INTERNAL_ENC_DIR=/var/lib/zabbix/enc_internal
+ '[' init_and_upgrade_db == init_and_upgrade_db ']'
+ echo 'sleeping 10 seconds...'
sleeping 10 seconds...
+ sleep 10
+ prepare_db
+ echo '** Preparing database'
** Preparing database
+ check_variables_postgresql
+ : postgres-cluster.sandpit-grove.factory.wf1
+ : 5432
+ file_env POSTGRES_USER
+ local var=POSTGRES_USER
+ local fileVar=POSTGRES_USER_FILE
+ local defaultValue=
+ '[' user ']'
+ '[' '' ']'
+ local val=
+ '[' user ']'
+ val=user
+ echo '** Using POSTGRES_USER variable from ENV'
** Using POSTGRES_USER variable from ENV
+ export POSTGRES_USER=user
+ POSTGRES_USER=user
+ unset POSTGRES_USER_FILE
+ file_env POSTGRES_PASSWORD
+ local var=POSTGRES_PASSWORD
+ local fileVar=POSTGRES_PASSWORD_FILE
+ local defaultValue=
+ '[' 'password' ']'
+ '[' '' ']'
+ local val=
+ '[' 'password' ']'
+ val='password'
+ echo '** Using POSTGRES_PASSWORD variable from ENV'
** Using POSTGRES_PASSWORD variable from ENV
+ export 'POSTGRES_PASSWORD=password'
+ POSTGRES_PASSWORD='password'
+ unset POSTGRES_PASSWORD_FILE
+ DB_SERVER_ROOT_USER=user
+ DB_SERVER_ROOT_PASS='password'
+ DB_SERVER_ZBX_USER=user
+ DB_SERVER_ZBX_PASS='password'
+ : public
+ DB_SERVER_DBNAME=zabbix
+ : false
+ '[' -n postgres-cluster.sandpit-grove.factory.wf1 ']'
+ psql_connect_args='--host postgres-cluster.sandpit-grove.factory.wf1 --port 5432'
+ check_db_connect_postgresql
+ echo '********************'
********************
+ '[' -n postgres-cluster.sandpit-grove.factory.wf1 ']'
+ echo '* DB_SERVER_HOST: postgres-cluster.sandpit-grove.factory.wf1'
* DB_SERVER_HOST: postgres-cluster.sandpit-grove.factory.wf1
+ echo '* DB_SERVER_PORT: 5432'
* DB_SERVER_PORT: 5432
+ echo '* DB_SERVER_DBNAME: zabbix'
* DB_SERVER_DBNAME: zabbix
+ echo '* DB_SERVER_SCHEMA: public'
* DB_SERVER_SCHEMA: public
+ '[' true == true ']'
+ echo '* DB_SERVER_ZBX_USER: user'
* DB_SERVER_ZBX_USER: user
+ echo '* DB_SERVER_ZBX_PASS: password'
* DB_SERVER_ZBX_PASS: password
+ echo '********************'
********************
+ '[' -n 'password' ']'
+ export 'PGPASSWORD=password'
+ PGPASSWORD='password'
+ WAIT_TIMEOUT=5
+ '[' false == false ']'
+ '[' -n public ']'
+ PGOPTIONS=--search_path=public
+ export PGOPTIONS
+ '[' -n '' ']'
+ true :
+ psql --host postgres-cluster.sandpit-grove.factory.wf1 --port 5432 --username user --list --quiet
+ psql --host postgres-cluster.sandpit-grove.factory.wf1 --port 5432 --username user --list --dbname zabbix --quiet
+ echo '**** PostgreSQL server is not available. Waiting 5 seconds...'
**** PostgreSQL server is not available. Waiting 5 seconds...
+ sleep 5
^C
zabbix-create-upgrade-db-snn5w:~$ 

Manual testing in the shell

zabbix-create-upgrade-db-snn5w:~$ export 'PGPASSWORD=password'
zabbix-create-upgrade-db-snn5w:~$ psql --host postgres-cluster.sandpit-grove.factory.wf1 --port 5432 --username user --list --quiet
                                                       List of databases
    Name     |    Owner    | Encoding | Locale Provider | Collate |  Ctype  | Locale | ICU Rules |      Access privileges      
-------------+-------------+----------+-----------------+---------+---------+--------+-----------+-----------------------------
 aerochronos | aerochronos | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =Tc/aerochronos            +
             |             |          |                 |         |         |        |           | aerochronos=CTc/aerochronos
 postgres    | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | 
 template0   | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres                +
             |             |          |                 |         |         |        |           | postgres=CTc/postgres
 template1   | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres                +
             |             |          |                 |         |         |        |           | postgres=CTc/postgres
 zabbix      | zabbix      | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | 
(5 rows)

zabbix-create-upgrade-db-snn5w:~$ psql --host postgres-cluster.sandpit-grove.factory.wf1 --port 5432 --username user --list --dbname zabbix --quiet
                                                       List of databases
    Name     |    Owner    | Encoding | Locale Provider | Collate |  Ctype  | Locale | ICU Rules |      Access privileges      
-------------+-------------+----------+-----------------+---------+---------+--------+-----------+-----------------------------
 aerochronos | aerochronos | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =Tc/aerochronos            +
             |             |          |                 |         |         |        |           | aerochronos=CTc/aerochronos
 postgres    | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | 
 template0   | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres                +
             |             |          |                 |         |         |        |           | postgres=CTc/postgres
 template1   | postgres    | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | =c/postgres                +
             |             |          |                 |         |         |        |           | postgres=CTc/postgres
 zabbix      | zabbix      | UTF8     | libc            | C.UTF-8 | C.UTF-8 |        |           | 
(5 rows)

zabbix-create-upgrade-db-snn5w:~$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions