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

passwordUpdateJob does not take custom database name dynamically #30830

Closed
nix-power opened this issue Dec 8, 2024 · 4 comments · Fixed by #31146
Closed

passwordUpdateJob does not take custom database name dynamically #30830

nix-power opened this issue Dec 8, 2024 · 4 comments · Fixed by #31146
Assignees
Labels
postgresql solved stale 15 days without activity tech-issues The user has a technical issue about an application triage Triage is needed

Comments

@nix-power
Copy link
Contributor

nix-power commented Dec 8, 2024

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

@nix-power nix-power added the tech-issues The user has a technical issue about an application label Dec 8, 2024
@github-actions github-actions bot added the triage Triage is needed label Dec 8, 2024
@carrodher
Copy link
Member

Thank you for bringing this issue to our attention. We appreciate your involvement! If you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team is excited to review your submission and offer feedback. You can find the contributing guidelines here.

Your contribution will greatly benefit the community. Feel free to reach out if you have any questions or need assistance.

@nix-power
Copy link
Contributor Author

Created PR

#31146

@carrodher
Copy link
Member

Thank you for opening this issue and submitting the associated Pull Request. Our team will review and provide feedback. Once the PR is merged, the issue will automatically close.

Your contribution is greatly appreciated!

Copy link

github-actions bot commented Jan 8, 2025

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postgresql solved stale 15 days without activity tech-issues The user has a technical issue about an application triage Triage is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants