Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database ping test fails when the username and dbname is different in initdb #368

Open
UgurcanAkkok opened this issue Aug 30, 2024 · 0 comments · May be fixed by #369
Open

Database ping test fails when the username and dbname is different in initdb #368

UgurcanAkkok opened this issue Aug 30, 2024 · 0 comments · May be fixed by #369
Labels
chart( cluster ) Related to the cluster chart

Comments

@UgurcanAkkok
Copy link

UgurcanAkkok commented Aug 30, 2024

Hi everyone,

The database-ping-test fails when i set the value of the database different from the owner in the initdb configuration.

Following is my configuration for cluster chart, I am using kustomize to deploy helm

helmCharts:
  - name: cluster
    version: 0.0.10
    releaseName: psql-gitea
    repo: https://cloudnative-pg.github.io/charts
    namespace: homelab
    valuesInline:
      cluster:
        instances: 1
        initdb:
          database: giteadb
          owner: gitea

And this results in the following error in the ping-test pod:

psql: error: connection to server at "psql-gitea-cluster-rw.homelab.svc.cluster.local" (10.43.64.140), port 5432 failed: FATAL:  database "gitea" does not exist

As you can see it tries to connect to gitea database, even though we specified it as giteadb
The connection string and pod configuration:

# psql-gitea-cluster-ping-test pod 
spec:
  containers:
  - args:
    - -c
    - apk add postgresql-client && psql "postgresql://$PGUSER:[email protected]:5432"
      -c 'SELECT 1'
    command:
    - sh
    env:
    - name: PGUSER
      valueFrom:
        secretKeyRef:
          key: username
          name: psql-gitea-cluster-app
    - name: PGPASS
      valueFrom:
        secretKeyRef:
          key: password
          name: psql-gitea-cluster-app
    image: alpine:3.17

When I manually try to connect with the giteadb, i can succesfully create a connection:

➜ kubectl exec -it psql-gitea-cluster-1 -c postgres -- psql 'postgresql://gitea:<AUTO_GENERATED_PASSWORD>@psql-gitea-cluster-rw.homelab:5432/giteadb' -c 'SELECT 1'
 ?column? 
----------
        1
(1 row)

So the problem is, in the test-pod there is no db specified so it (by default) tries to connect to a db with the same name as the user. As there is no db created as such, it fails.

UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Aug 30, 2024
@UgurcanAkkok UgurcanAkkok linked a pull request Aug 30, 2024 that will close this issue
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Aug 30, 2024
@UgurcanAkkok UgurcanAkkok changed the title Helm test hook fails when the username and dbname is different in initdb Database ping test fails when the username and dbname is different in initdb Aug 30, 2024
@itay-grudev itay-grudev added the chart( cluster ) Related to the cluster chart label Sep 4, 2024
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Sep 6, 2024
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Sep 9, 2024
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Sep 9, 2024
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Nov 6, 2024
UgurcanAkkok added a commit to UgurcanAkkok/cloudnative-pg-charts that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chart( cluster ) Related to the cluster chart
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants