UPGRADE FAILED: cannot patch "gitea-postgresql" with kind StatefulSet #452
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First time having issue with gitea upgrade.
I was on v1.18.1 gitea and trying to upgrade to v1.19.3 using same values as before.
I went and patch
gitea-postgresql
secret and copy the old key to the new name as required. Reran the upgrade and got:I can see gitea 1.19 is working and db tables are upgraded but the above error tell me postgres image is not updated.
Any pointers?
From which Helm chart version did you update? And to which Chart version? You might have to redeploy postgres due to dependency updates.
Jup make sure to check https://gitea.com/gitea/helm-chart#to-8-0-0 - requires a manual DB upgrade of the postgres pod
We had another user before in discord who reported that. steps are:
Or - recommended alternative - go with an external DB that is not managed by the chart for which you have more control :)
OK. so I endded up in a bit of drama. Gitea was upgraded to 1.19 and hence db tables has been upgraded on PG 11.
Uninstalled and reinstalled helm chart.
PG 15 couldn't load due to old version of
data
directory. PG 15 requires manual update from PG 11. This requires configuring and running manual jobs.Downgraded to gitea 1.18. DB came up but gitea didn't as there was changes to DB table.
Upgraded to Gitea 1.19 to get gitea running. Now it runs with PG 11 but helm chart fails (errors in my original post).
Using external DBs is not an option for me.
Couldn't upgrade 11 to 15 be scripted as part of the chart? I think a lot of people gonna have similar situation like me as PG upgrade is not straight forward given everything was managed by helm chart before.
Regarding the release note, I think a "breaking change" notice should be included and it should clearly state "DB requires manual upgrade".
Sorry to hear you've faced issues.
A major version bump implies breaking changes and the update of the PG version is mentioned there. There is no "simple upgrade path" from a dockerized DB version to another major version that could just be done by the helm chart (https://www.cloudytuts.com/tutorials/docker/how-to-upgrade-postgresql-in-docker-and-kubernetes/). We also can't stick with an old PG version forever.
PRs to improve the update experience are always welcome - we all do this with "best effort" in our spare time.
You can always run a standalone PG besides the gitea container that is not managed by the helm-chart. It doesn't need to be a managed-DB in the cloud.
OK, I managed to get things working with PG 15 (it was also okay to continue using PG 11 but helm upgrade fail).
It was not a straight forward upgrade due to some issue which I explain below.
Create a SQL dump of your old gitea database:
kubectl exec -it gitea-postgresql-0 -- pg_dumpall -U postgres > /tmp/gitea.sql
NOTE: If you don't know the postgres password, run
sed -ibak 's/^\([^#]*\)md5/\1trust/g' /opt/bitnami/postgresql/conf/pg_hba.conf && pg_ctl reload
to remove the password requirement locally (see https://docs.bitnami.com/virtual-machine/infrastructure/postgresql/administration/change-reset-password/)Copy it locally
kubectl cp ....
Edit the
gitea.sql
and comment lines where itCREATE ROLE postgres
andALTER ROLE postgres
. ChangeALTER DATABASE gitea OWNER TO postgres
toALTER DATABASE gitea OWNER TO gitea
If you don't you may lose access to postgres (I couldn't find the postgres password that was used in PG 11).Create a new postgres db. Many options here.
Copy
gitea.sql
to your new postgres:kubectl cp ...
Restore the backup to your new postgres:
kubectl exec -it gitea-postgres-new -- psql -U postgres < /tmp/gitea.sql
Modify gitea helm chart to disable postgres but add your new postgres credentials:
BUG: if you postgres service name is different, gitea initilisation script still points to old postgres service name. You need to update K8S secret > gitea-inline-config > database with name of your new postgres service. If you don't do this, gitea pod will never come up when you upgrade (attn @pat-s)
Apply helm upgrade. Gitea should come up with no issue.
BUG: I found webhooks fail in DB migrations:
Therefore, make sure to create the webhook again.
@pi3ch Thanks for the detailed instructions! These could make it into an official document to help other users along the way. I could think of a simple
.md
document in a new directorydocs/
in the repo titledpostgres-upgrade-instructions.md
or similar.Would you be motivated to port your comment into a doc?
We're aware that the process is of conducting a major update of a DB is not a trivial one. However, everybody has a different setup and it's hard for us (and partly out-of-scope) to provide instructions how to maintain all dependencies in this chart.
That was also part of the motivation why we removed all the other DB types lately - just to have less issues WRT to dependencies.
And congrats on getting it working! 🎉 I am sure it took more than just a few minutes...
Is this due to how bitnami names it, i.e. caused by the PG chart update? Overall this sounds a bit as if a clean init of
app.ini
could help here, see #356 and others for more information (tldr, we're aware of it).