-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[postgresql] bug: password authentication failed for user "postgres" #2061
Comments
This is almost definitely related to a lot of previous issues around the secret and the database getting out of sync due to existing volumes and whatnot. See here; helm/charts#16251 That said I know that thread claims this is essentially expected behavior but it's still really terrible UX. Would it be possible to investigate syncing the password from the secret on pod startup? No idea if it's something that even can be done since it's working around auth a bit but... If the secret has a password people are expecting that to drive the password rather than simply be a duped, possibly out of sync, output of it. I'd be happy to look into it but I'm not a PG guru |
Hi, Thank you very much for your feedback. In some applications, get the password updated when restoring from persistence is not trivial, and could lead to unexpected issues. Having said that, it may be possible to explore it in the case of PostgreSQL in order to improve the user experience. It is not a critical feature so we cannot guarantee an ETA, but we will update the ticket when we have updates on this. |
I'm trying out this chart. Auth seems to always fail when specifying a password. Also tested it with the auto-generated password and got the same result. helm search repo postgres
NAME CHART VERSION APP VERSION DESCRIPTION
bitnami/postgresql 8.6.12 11.7.0 Chart for PostgreSQL, an object-relational data...
bitnami/postgresql-ha 2.0.4 11.7.0 Chart for PostgreSQL with HA architecture (usin...
helm install psql --set postgresqlPassword=hello bitnami/postgresql
export POSTGRES_PASSWORD=$(kubectl get secret --namespace default psql-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
echo $POSTGRES_PASSWORD
hello
kubectl port-forward --namespace default svc/psql-postgresql 5433:5432 &
Forwarding from 127.0.0.1:5433 -> 5432
Forwarding from [::1]:5433 -> 5432
PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5433
Handling connection for 5433
psql: error: could not connect to server: FATAL: password authentication failed for user "postgres" Tried every combo of
Update: this was on minikube with docker driver which is apparently buggy. Switched to a real cluster, made some progress, but it seems that |
@devth I'm a devops novice generally speaking so my apologies if this doesn't help. Based on @kav's comment and reading through the issue he linked, it appears that postgres copies the password into some internal storage when you install it the first time and, regardless of what you do in future installs (such as regenerating the password), the database will only ever answer to the original credentials. However, if you have anything trying to connect to the db it may use the updated creds and so fail to install. Sorry I can't be more specific. Hopefully the linked issue can help. In my case, I was installing postgres for artifactory. Since I couldn't get the install to work, I just used artifactory's built in db installer. |
@joe-sonrichard thanks, that helps! helm/charts#16251 helped a ton, I hadn't found that issue. I think what was going on was I was deleting my infra via After ensuring the PVC was deleted and re-testing everything it finally works! |
Good to know that it worked for you! We will check if there's an easy way of recreating the passwords when changing them, though it is not trivial. We will update when we have more news :) |
Hi Everyone, Below is the pg_hba.conf file, after my change.
Once strange thing that I am observing is, when I am changing the pg_hba.conf file using --set flag the postgres pod that gets spinned up actually restarts once, but not in the other case where I dont set the parameter. |
Hi, Something tells me that it has to do with having a pg_hba.conf not compatible with the initial database setup. Note that it gets modified several times. Could you elaborate more on the use case that you want to achieve with your custom pg_hba.conf? |
Sure, so I want to run some database operations for example connecting to it and inserting some records into the test database. I would be |
Hi, I believe the issue is because it conflicts with the initialization. Could you try the following?
|
Hey @javsalgar |
So as stated in some comments I was finally able to fix the issue by deleting PVCs and redeploy the Chart #!/bin/bash
helm delete postgresql
kubectl get pvc -l "app=postgresql"
kubectl delete pvc -l "app=postgresql"
helm install postgresql --version 8.7.3 \
--set postgresqlUsername=postgres \
--set postgresqlPassword=postgres \
bitnami/postgresql |
@jmarcos-cano fantastic find! I reckon if you're using helmfile you can apply a cleanup hook: https://github.com/roboll/helmfile#hooks |
I think it's a problem of two sources of truth: one in the DB volume and one in the k8s secret. |
Hi, This is something that we internally need to discuss. I agree that it's something that can be confusing, as you cannot modify the password using env vars or doing helm upgrade. This is not trivial, and we should find a process that makes sense for all of the charts. I will forward this feedback to the rest of the team, thank you very much for the input! |
Hi, not sure I understood the status of this issue. I just tried to install the last postgres chart (release v9.1.2) and i failed login to psql using postgres user.
It is a fresh installation without data. The values file is as follows:
Any clues ? |
Hi @yaakov-berkovitch, could you share the content, at least the structure, of your secret |
I am facing this problem where i am not able to login with postgress user. The postgresql was installed using bitnami: When i try to login is get error: This is the pod spec: Not sure whats wrong? |
Hi, We would require more details on how you deployed the chart. Which values did you set? Which is your Kubernetes platform? |
Used Helm2 to deploy the chart. I think the porblem was this value.
If i set a non-super DB user then i will only get create DB permission on that DB. One can't switch user to superuser once you initialize DB(container/pod) without postgres(superuser) user and password. For workaround, i had to create new pvc and then intialize the DB with postgres username and password. What i personally think is that there must be a default password for postgres user that could be used in this case, it should be upto user to change the password if they want. |
You would also need to set the |
Try editing: pg_hba.conf with:
|
Might be worth looking at the lookup function to see if a password already exists during upgrade and leaving it in place if it does. https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function |
Hi! Thanks for the tip! I was not aware of this function. Right now we are doing checks to ensure that the password is re-introduced when upgrading. |
I gave it a go and it seems to work ... #4416 |
Thanks for the PR, we have an internal task created to review if the |
Hello Team, org.postgresql.util.PSQLException: FATAL: password authentication failed for user "dbfuser" If I add say few more databases on single replica, this would not going to serve my purpose therefore I am in need to scale up postgres using multiple replica on demand. This error is blocking to me and till them relying on Vertical Scaling. Any suggestion! |
It's funny to see such unresolved issues in IT 👯
|
Hi! I am unable to reproduce the issue
Could you provide more details about your Kubernetes cluster? |
Do you know the type of storage node it uses, do the logs show anything meaningful regarding the error? |
When I tried it, I did not see any errors. I can say 1, the first time I ran in a cluster, the password worked, then I did helm uninstall, and tried the same command with a different password, the password stopped setting |
I tried using the name |
Could it be that you weren't removing the PVCs from the previous release? Therefore, if there was persistence from a previous installation, the password you were setting would not be changed. |
In my case, this error was due to me not defining the username and database name in the yaml config file of postgres deployment. So one way to hack the problem might be by making sure that we have defined the username and database name in the deployment config files. For more info, feel free to visit here. |
@javsalgar Try installing it just like you did but without altering the generated password, then uninstalling it with However, if after uninstalling it you delete the pvc the error will not happen when you next install it. |
Hi, Yes, that is expected when you re-use PVCs from previous releases. I'm afraid that helm delete does not delete StatefulSet PVCs. |
For folks reaching this with recent updates to the chart, you can delete the leftover PVC with:
|
Hi everyone! PVC(s) leftovers is a common known issue, and we have a Troubleshooting guide that explains how to workaround it: |
I also wasn't able to login with the It should be named
A quick fix that worked for me is:
|
Hi @jknipper What image are you using? It's kind unlikely that the issue is related to that env. variable name since both env. vars are aliases in the Bitnami PostgreSQL images, see: |
Hmm, you are right @juan131. Maybe it's my outdated image, I am using |
I'm still facing same issue after deleting helm chart and PVC also:
After deleting i am trying to re-install.
When i execute this command showing me correct password which i set while installing postgres through helm - When i execute into postgres pod and try to connect to postgres with both users (admin and postgres) password authentication failed for user "postgres" and "admin". I tried with version 8.7.3 which is mentioned by @jmarcos-cano but didn't work. |
Hi, I've been unable to reproduce the issue:
|
It is showing me error on both -
|
Hi, Definitely it seems to me there is an issue with the PVCs (which is weird, as you mentioned they were removed), could you try with a different release name to ensure there are no conflicting PVCs. |
I had the same issue, performed these steps: uninstall the chart, delete the PVC and reinstall it, it solved my issue. |
Unfortunately, this issue was created a long time ago and although there is an internal task to fix it, it was not prioritized as something to address in the short/mid term. It's not a technical reason but something related to the capacity since we're a small team. Being said that, contributions via PRs are more than welcome in both repositories (containers and charts). Just in case you would like to contribute. During this time, there are several releases of this asset and it's possible the issue has gone as part of other changes. If that's not the case and you are still experiencing this issue, please feel free to reopen it and we will re-evaluate it. |
Which chart:
postgresql v8.6.4
Description
Admin user (postgres) password fails with or without default settings.
Steps to reproduce the issue:
helm install artifactory -f postgresql-values.yaml bitnami/postgresql
Describe the results you received:
Error text:
Describe the results you expected:
I expected it to work.
Additional information you deem important (e.g. issue happens only occasionally):
Note that this happens the same way if you un-comment the
existingSecret
line.Version of Helm and Kubernetes:
helm version
:version.BuildInfo{Version:"v3.1.2", GitCommit:"d878d4d45863e42fd5cff6743294a11d28a9abce", GitTreeState:"clean", GoVersion:"go1.13.8"}
kubectl version
:The text was updated successfully, but these errors were encountered: