Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Cannot connect to PostgreSQL with default values.yaml #329

Open
Oznup opened this issue Jan 21, 2022 · 1 comment
Open

Cannot connect to PostgreSQL with default values.yaml #329

Oznup opened this issue Jan 21, 2022 · 1 comment

Comments

@Oznup
Copy link

Oznup commented Jan 21, 2022

Hello,

First of all congratulations for this beautiful chart 😉

Today I'm trying to install SonarQube on my self hosted kubernetes cluster, and I meet an issue : Sonar can't get connected to the PostgreSQL database deployed by the same chart, using the password in the secret.

I think you know which error I mean :

java.lang.IllegalStateException: Fail to connect to database
        at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:86)
        [...]
Caused by: java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
        [...]
Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user "sonarUser")
        [...]
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sonarUser"
        [...]

What is really weird, is that when I do kubectl get deploy sonarqube -o yaml I can see that the secret is used.

[...]
- name: SONAR_JDBC_PASSWORD
          valueFrom:
            secretKeyRef:
              key: postgresql-password
              name: sonar-postgresql
[...]

So, here is my overrides.yaml file, but you'll see, there is nothing really important :

postgresql:
  enabled: true

persistence:
  enabled: false

What am I missing ?

Thanks for your help

@Oznup Oznup changed the title Cannot connect to PostgreSQL on dumb blank configuration Cannot connect to PostgreSQL with default values.yaml Jan 22, 2022
@milapj
Copy link

milapj commented Feb 3, 2022

I'm facing the same issue, and expanding on this a little more -

I tried deploying the helm chart on a minikube cluster. It fails with the same error, container logs -

Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sonarUser"
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:613)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:161)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
	at org.postgresql.Driver.makeConnection(Driver.java:465)
	at org.postgresql.Driver.connect(Driver.java:264)

When I do helm get all sonarqube -n sonarqube I can see the secret sonar-postgresql is used -

containers:
        - name: sonarqube-postgresql
          image: docker.io/bitnami/postgresql:11.7.0-debian-10-r26
          imagePullPolicy: "IfNotPresent"
          resources:
            limits:
              cpu: 2
              memory: 2Gi
            requests:
              cpu: 100m
              memory: 200Mi
          securityContext:
            runAsUser: 1001
          env:
            - name: BITNAMI_DEBUG
              value: "false"
            - name: POSTGRESQL_PORT_NUMBER
              value: "5432"
            - name: POSTGRESQL_VOLUME_DIR
              value: "/bitnami/postgresql"
            - name: PGDATA
              value: "/bitnami/postgresql/data"
            - name: POSTGRES_USER
              value: "sonarUser"
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: sonar-postgresql
                  key: postgresql-password
            - name: POSTGRES_DB
              value: "sonarDB"
            - name: POSTGRESQL_ENABLE_LDAP
              value: "no"

I also tried setting a couple of properties when deploying but no luck.

helm install sonarqube oteemocharts/sonarqube --set readinessProbe.initialDelaySeconds=180,livenessProbe.initialDelaySeconds=180,createPostgresqlSecret=true -n sonarqube

Looking at postgres container logs did not provide anything insightful and I'm not able to log into the db too. I think the root cause might be in this logic or I'm missing something obvious 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants