Skip to content

chore: postgres 17 upgrade#819

Merged
DerekRoberts merged 49 commits intomainfrom
chore/postgres17
Aug 6, 2025
Merged

chore: postgres 17 upgrade#819
DerekRoberts merged 49 commits intomainfrom
chore/postgres17

Conversation

@DerekRoberts
Copy link
Member

@DerekRoberts DerekRoberts commented Jun 26, 2025

All files are in the ./db folder. Steps are expected to be run accordingly.

./rename_deployment.sh <source-deployment-name> [target-deployment-name]

  • exports a deployment manifest
  • deletes fields (status, some metadata)
  • modifies deployment (name, labels)
  • redeploys the renamed deployment
  • watches rollout to completion/failure
  • deletes the old deployment, maintains its pvc

./db_transfer.sh <source-deployment-name> <target-deployment-name>

  • verifies that source PVC is older than destination PVC (allows override)
  • streams pg_dump to pr_restore between postgres containers
  • excludes postgis schemas (tiger, tiger_data, topology)

Steps:

# Set target to `819` (this PR), `test` or `prod`
TARGET=819

# 1. Scale down api
oc scale deployment fom-${TARGET}-api --replicas=0

# 2. Rename the old db
cd db
./rename_deployment.sh fom-${TARGET}-db

# 3. Deploy the new db
oc process -f openshift.deploy.yml -p ZONE=${TARGET} -p TAG=${TARGET} | oc apply -f -

# 4. Verify PostGIS extension version = 3.6
oc exec -i deployment/fom-${TARGET}-db -- bash -c "psql -U \$POSTGRES_USER -d \$P
OSTGRES_DB -c 'SELECT PostGIS_Version()'"

# 5. Stream dump from old to new db
./db_transfer.sh fom-${TARGET}-db-prev fom-${TARGET}-db

# 6. Scale up api
oc scale deployment fom-${TARGET}-api --replicas=3

Before merge:

  • We need to run these steps on TEST and PROD
  • Uncomment/restore image in template (temporarily patched)

Thanks for the PR!

Deployments, as required, will be available below:

Please create PRs in draft mode. Mark as ready to enable:

After merge, new images are deployed in:

Copy link
Contributor

@ianliuwk1019 ianliuwk1019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Derek!
Some comments, may mostly due to I am not clear for the procedure.

  • The "steps" in this PR summary probably can be in some readme in db so the developers have idea how to follow to run manual scripts.
  • Are the shell scripts required for elevated access to OpenShift to execute them?
  • Not clear how it can be rollback if error happens? Or pointing back to old pvc/deployment?
  • Is it ok if we can test this in PR (dev) environment first, by: testing from v13 -> v16 -> dummy trigger (regular) deployment (within pr) -> then v17 (just to be safe to see the process works)?

@DerekRoberts
Copy link
Member Author

DerekRoberts commented Jul 11, 2025

Thank you Derek! Some comments, may mostly due to I am not clear for the procedure.

  • The "steps" in this PR summary probably can be in some readme in db so the developers have idea how to follow to run manual scripts.

These scripts assist with the standard upgrade procedure for postgres, which is to export from the old and import to the new. Feel free to create docs or link to something appropriate.

  • Are the shell scripts required for elevated access to OpenShift to execute them?

OpenShift admin rights are assumed. We can try with less.

  • Not clear how it can be rollback if error happens? Or pointing back to old pvc/deployment?

There are two separate databases. If the new one is unacceptable we delete it and give the old database it's name back. PR merge only happens after successful migrations.

  • Is it ok if we can test this in PR (dev) environment first, by: testing from v13 -> v16 -> dummy trigger (regular) deployment (within pr) -> then v17 (just to be safe to see the process works)?

There will be no triggers, because this is a manual process. Running a demo in PR is a lot safer than TEST or PROD, so of course we can do that!

@github-project-automation github-project-automation bot moved this from Waiting to Done in DevOps (NR) Jul 11, 2025
@DerekRoberts DerekRoberts reopened this Jul 11, 2025
@github-project-automation github-project-automation bot moved this from Done to Parked in DevOps (NR) Jul 11, 2025
@DerekRoberts DerekRoberts force-pushed the chore/postgres17 branch 2 times, most recently from 168f83c to c83dc03 Compare July 11, 2025 17:35
@DerekRoberts DerekRoberts moved this from Parked to Waiting in DevOps (NR) Jul 15, 2025
@MCatherine1994
Copy link
Contributor

Hi @ianliuwk1019 @DerekRoberts, I added a Readme file to capture the process and steps we walked through together today. Feel free to take a look! Thanks!

Copilot AI review requested due to automatic review settings July 28, 2025 23:59
@DerekRoberts DerekRoberts merged commit 77b26ef into main Aug 6, 2025
19 of 21 checks passed
@DerekRoberts DerekRoberts deleted the chore/postgres17 branch August 6, 2025 00:36
@github-project-automation github-project-automation bot moved this from Waiting to Done in DevOps (NR) Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Postgis v17

5 participants