Skip to content

passwordUpdateJob does not take custom database name dynamically #30830

@nix-power

Description

@nix-power

Name and Version

bitnami/postgres: 16.2.5

What architecture are you using?

amd64

What steps will reproduce the bug?

the following code in a helm template job.yaml for passwordUpdateJob

   - |
              {{- $customUser := include "postgresql.v1.username" . }}
              {{- if .Values.usePasswordFiles }}
              # We need to load all the secret env vars to the system
              for file in $(find /bitnami/postgresql/secrets -type f); do
                  env_var_name="$(basename $file)"
                  echo "Exporting $env_var_name"
                  export $env_var_name="$(< $file)"
              done
              {{- end }}

              . /opt/bitnami/scripts/postgresql-env.sh
              . /opt/bitnami/scripts/libpostgresql.sh
              . /opt/bitnami/scripts/liblog.sh

              primary_host={{ include "postgresql.v1.primary.fullname" . }}-0.{{ include "postgresql.v1.primary.svc.headless" . }}
              info "Starting password update job"
              {{- if .Values.auth.enablePostgresUser }}
              if [[ -f /job-status/postgres-password-changed ]]; then
                  info "Postgres password already updated. Skipping"
              else
                  info "Updating postgres password"
                  echo "ALTER USER postgres WITH PASSWORD '$POSTGRESQL_NEW_POSTGRES_PASSWORD';" | postgresql_remote_execute $primary_host {{ .Values.containerPorts.postgresql }} "" postgres $POSTGRESQL_PREVIOUS_POSTGRES_PASSWORD
                  touch /job-status/postgres-password-changed
                  info "Postgres password successfully updated"
              fi
              {{- end }}
              {{- if and (not (empty $customUser)) (ne $customUser "postgres") }}
              if [[ -f /job-status/password-changed ]]; then
                  info "User password already updated. Skipping"
              else
                  info "Updating user password"
                  echo "ALTER USER {{ $customUser }} WITH PASSWORD '$POSTGRESQL_NEW_PASSWORD';" | postgresql_remote_execute $primary_host {{ .Values.containerPorts.postgresql }} "postgres" $POSTGRESQL_USER $POSTGRESQL_PREVIOUS_PASSWORD
                  touch /job-status/password-changed
                  info "User password successfully updated"
              fi

users hardcoded name of "postgres" for the user-defined database instead of taking in dynamically from postgresql.auth.database variable from values.yaml if defined.

Are you using any custom parameters or values?

postgresql:
  auth:
    database: my-database

What is the expected behavior?

i am expecting to use

echo "ALTER USER {{ $customUser }} WITH PASSWORD '$POSTGRESQL_NEW_PASSWORD';" | postgresql_remote_execute $primary_host {{ .Values.containerPorts.postgresql }} "{{ .Vaules.auth.database }}" $POSTGRESQL_USER $POSTGRESQL_PREVIOUS_PASSWORD

if Values.auth.database is defined, otherwise only use "postgres"

What do you see instead?

hardcoded "postgres" name for user-defined databse

Metadata

Metadata

Assignees

Labels

postgresqlsolvedstale15 days without activitytech-issuesThe user has a technical issue about an applicationtriageTriage is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions