In the hopes that this will save someone from floundering for as many hours as I did in this predicament, here is the process that finally allowed me to upgrade from Discourse v3.0.6 to v3.2.0 in the context of using Bitnami Helm chart (v11 to v12). While further disclaimers should not be necessary based on comments above, this problem is due to a bug in Bitnami’s Helm chart and their custom images; the problem does not affect official Discourse releases.
The instructions below show how to navigate the upgrade. The “production site” is a Helm chart release of the Discourse site being upgraded, and “migration site” refers to a temporary chart release deployed in parallel in namespace discourse-dev.
Production site
- Set production forum to read-only mode in Backups admin panel /admin/backups.
- Make backup using Backups admin panel. Download backup archive locally.
Migration site
-
Install fresh instance of Bitnami chart v12.6.2 (Discourse v3.2.0). Scale the Discourse server Deployment to zero.
$ kubectl scale -n discourse-dev deployment discourse --replicas 0 deployment.apps/discourse scaled -
Create SQL file
db_init.sql:cat > /tmp/db_init.sql << EOF DROP DATABASE bitnami_application; CREATE DATABASE bitnami_application; GRANT ALL PRIVILEGES ON DATABASE bitnami_application TO bn_discourse; CREATE EXTENSION hstore; CREATE EXTENSION pg_trgm; ALTER database bitnami_application owner to bn_discourse ; EOF -
Copy to the database pod and execute:
$ kubectl cp -n discourse-dev db_init.sql discourse-dev-postgresql-0:/tmp/ $ kubectl exec -n discourse-dev -it discourse-dev-postgresql-0 -- bash -c \ 'PGPASSWORD=$POSTGRES_PASSWORD psql -U postgres \ < /tmp/db_init.sql' DROP DATABASE CREATE DATABASE GRANT ERROR: extension "hstore" already exists ERROR: extension "pg_trgm" already exists ALTER DATABASE -
Extract backup archive, copy SQL dump file to database pod, and apply:
$ ls discourse-2024-03-04-143102-v20230119094939.tar.gz $ tar xvf discourse-2024-03-04-143102-v20230119094939.tar.gz $ gunzip dump.sql.gz $ kubectl cp -n discourse-dev dump.sql discourse-dev-postgresql-0:/tmp/ $ kubectl exec -n discourse-dev -it discourse-dev-postgresql-0 -- bash -c \ 'PGPASSWORD=$POSTGRES_PASSWORD psql -U bn_discourse \ --dbname bitnami_application \ < /tmp/dump.sql' -
Launch Discourse pod.
$ kubectl scale -n discourse-dev deployment discourse --replicas 1 deployment.apps/discourse scaled -
Watch logs and drop tables that are preventing the upgrade:
$ kubectl logs --prefix -f -n discourse-dev -c discourse -l app.kubernetes.io/name=discourse $ kubectl logs --prefix -f -n discourse-dev -l app.kubernetes.io/name=postgresql -
Watch while db migrations fail and manually delete the relevant tables until migrations succeed:
$ kubectl exec -n discourse-dev -it discourse-dev-postgresql-0 -- bash -c \ 'PGPASSWORD=$POSTGRES_PASSWORD psql -U bn_discourse --dbname bitnami_application -c "\ DROP TABLE sidebar_sections; \ DROP TABLE sidebar_urls; \ DROP TABLE chat_threads; \ DROP TABLE form_templates; \ DROP TABLE category_settings; \ DROP TABLE category_form_templates; \ DROP TABLE theme_svg_sprites; \ DROP TABLE user_chat_thread_memberships; \ DROP TABLE summary_sections; \ "' -
Restore uploads folder backup:
$ PODNAME=$(kubectl get pod -n discourse-dev -l app.kubernetes.io/name=discourse --output=jsonpath={.items..metadata.name} | cut -f1 -d' ') $ kubectl cp -n discourse-dev -c discourse uploads $PODNAME:/bitnami/discourse/public/ $ kubectl exec -n discourse-dev -c discourse $PODNAME -- bash -c 'chown -R 999:0 /bitnami/discourse/public/uploads/' -
For some reason, the plugins did not automatically download and install. Do this manually and verify plugin functionality.
root@discourse-54c6d6fb7c-z9285:/bitnami/discourse/plugins$ git clone https://github.com/discourse/discourse-oauth2-basic root@discourse-54c6d6fb7c-z9285:/bitnami/discourse/plugins$ git clone https://github.com/discourse/discourse-math root@discourse-54c6d6fb7c-z9285:/bitnami/discourse/plugins$ chown -R 999:0 discourse-oauth2-basic discourse-math -
Create a backup of the newly restored site using Backups admin panel.
Production site
- Delete the original deployment and purge PV/PVCs.
- Install fresh instance of Bitnami chart v12.6.2 (Discourse v3.2.0).
- Use
https://$BASE_URL/u/admin-loginto login by email link. - Upload and restore backup archive using Backups admin panel.