Repository navigation
chore(deps): PostgreSQL 18 with an automatic, non-destructive upgrade from 17 - #216
Yoshiofthewire wants to merge 2 commits into
Conversation
… from 17 KyMessages' Matrix Postgres (Docker) and the replicated KyIdentity's database pod (Kubernetes) move to 18.7, pinned by digest. A 17 install moves on its next deploy by dump and restore with the suite's kit v2 (scripts/postgres-17-to-18.sh, byte for byte, sha256 2992644...): a 17.12 one-shot dumps the old data once, 18 restores it beside it, and the 17 data is only read, so the previous release still starts on it. - kymessage: postgres-17-dump one-shot (no network, restart "no") that postgres waits for; ./pgdata mounted at /var/lib/postgresql; the kit is a catalog file (pg-upgrade/). Its testdata copy of KyMessage's compose is fe88a59's. - Catalog: services others wait for with service_completed_successfully are Once: labelled, run by up, never asked to be running or healthy. Plain apps may bind files/. - upgrade.move gates on the target's layout, not versions: an unmoved install is backed up first where kyquickstart backup can, else needs --acknowledge-no-backup. - KyIdentity database pod: init container postgres-17-dump (17), the kit inline in the pod spec, claim at /var/lib/postgresql, 120 s grace. - CloudNativePG clusters stay on 17: there is no installer backup of a Cluster to take before its major upgrade. - scripts/test-postgres-17-to-18.sh (rendered kymessage Compose) and test-postgres-17-to-18-pod.sh (rendered pod spec in Docker), CI job "PostgreSQL 17 to 18 upgrade", required by release-image.yml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process: ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵🧪 PR contains tests⚡ No major issues detectedAdvisory only: this comment never gates the pull request. |
Security review - clearedDetail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kyquickstart-216, where it is readable by the operator and expires seven days after the last post. gpt-6.1-sol using security-audit on behalf of Yoshi |
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. gpt-6.1-sol using security-audit on behalf of Yoshi |
Kit v4 (sha256 195ae86..., byte for byte in scripts/, kymessage's pg-upgrade/ and internal/kube/): after a rollback that ran 17, a return to 18 refuses instead of silently starting the older 18; the marker sits at 18/moved-from-17.checkpoint, so removing upgrade-from-17/ is safe. - dockerhost: a Once service that exited non-zero fails health, up and start at once with its last logs; one that exited 0 is done. - kube: the database pod's dump init container keeps its last lines as its termination message, and health's reason quotes it. - e2e stackHealthy: expects the catalog's services plus its one-shots, accepts Exited (0) and fails with logs on any other exit (the kube-message-apply failure at 3b89e5a). - Both upgrade tests gain: write on 17 after a rollback, refused return, move again (row on 18, replaced 18 kept), keep 18, and the dump clean-up followed by a refused rollback. The Compose test's cleanup now passes KYQ_UID, so it no longer leaks networks. - docs/guided-setup.md: the way back to 18 and the safe clean-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire Fixed in 02e5c57. A return to 18 after 17 has run now refuses instead of starting the older 18. This is kit v4 (sha256
New case in The pod test runs the same cases: Each follow-up case is checked as well:
Run with kit v2 on the new side, the case fails with "18 started after 17 ran since the move". |
In one line: KyMessages' Matrix Postgres (Docker) and the replicated KyIdentity's database pod (Kubernetes) move to PostgreSQL 18. A 17 install moves itself on its next deploy and keeps the 17 data. CloudNativePG clusters stay on 17.
What changed
scripts/postgres-17-to-18.sh, sha256195ae86…). A 17.12 one-shot dumps the old data once, and 18 restores it beside the old data. The 17 data is only read, so the previous release still starts on it.18/), or keep 18 (delete18/moved-from-17.checkpoint). Removingupgrade-from-17/stays safe. This fixes the Guide's "Stale Migration".e2e (kube-message-apply)). A one-shot that exited 0 counts as done everywhere. On Docker, one that exited non-zero failsapply/start/health at once, with its last 40 log lines. On Kubernetes, health's reason quotes the dump init container's termination message.postgres-17-dump(no network,restart: "no"), andpostgreswaits for it../pgdatais now mounted at/var/lib/postgresql. The kit ships as a catalog file (pg-upgrade/). This is the same shape as KyMessage-Serverfe88a59(chore(deps): Bump github.com/Busnes-app/ky-primitives from 0.10.0 to 0.10.1 in the ky-primitives group #152).upgrade.move, keyed on the target's data layout, not on versions. An install that has not moved is backed up first (kyquickstart backup) when the target has a destination. If that backup fails, nothing is deployed. Without a destination, the deploy refuses (ack_required) until--acknowledge-no-backup.service_completed_successfullyis now "Once": it is labelled and run byup, and health never asks it to be running. Apps without native mail may now bindfiles/.postgres-17-dump(17 image). The kit runs inline in the pod spec, the claim is mounted at/var/lib/postgresql(theprivatesubPath), and the termination grace is 120 s.postgres_clusterstays 17.12. KyQuickStart has no backup of aClusterto take before CloudNativePG's major upgrade. Posted as BLOCKED to the owner on the board (ky-postgres-18).Review this
postgresql17-client. Its consolepg_dumprefuses an 18 server, so the console's own Matrix backups break if this merges before the catalog pins a KyMessage-Server release that contains fe88a59. No such release exists yet (latest is v0.6.1.1).internal/cli/suite.gomoveGate: decides backup, refusal or acknowledgement.internal/catalog/catalog.gocheckCompose: the Once classification. A wrongly classified service would be skipped by health.internal/dockerhost/health.gofailedOnce/upFailed: a failed one-shot now ends health andupwithout waiting for the timeout.Checked
scripts/test-postgres-17-to-18.shPASS on Major. It renders kymessage from the previous catalog (950c3f8) and from this one, then covers:up -dover the running 17; a refused dump beside a live 17 that writes nothing; rows, C collation and checksums; passwords checked from another container, with a wrong password refused; rollback to 17 with a write on 17; a refused return to 18 ("has run on … since it was moved to 18", PostgreSQL not started); move again (row on 18,18.replacedkept); keep 18 (accepted twice); removingupgrade-from-17/and then starting again, followed by a rollback that is still refused; a no-op rerun; a bad dump that never yields a cluster; a fresh install; a 17 backup restored on 18 with the manifest'srestore_command.Mutations of that test fail as they should: a plain image bump fails with "no such service: postgres-17-dump"; the pre-v2 kit fails with "dump ran beside a live 17". With kit v2 as the new side: "18 started after 17 ran since the move". With kit v3: "18 did not start after the dump was removed".
scripts/test-postgres-17-to-18-pod.shPASS. It runs the rendered previous and new pod specs in Docker as a kubelet would: subPath mounts, read-only root, uid 70, fsGroup. It covers the live-17 refusal, the move, the password checks, rollback, the same v4 return, move-again, keep-18 and clean-up cases, a rerun and a fresh claim. A plain image bump fails it, kit v2 fails with "dump accepted a 17 that ran since the move", and kit v3 with "source-checkpoint: No such file or directory".One-shot health:
TestOnceExitCode(dockerhost) andTestHealthReportsFailedDump(kube). Reverting either fix fails its test.Unit tests for the gate (
move_test.go):--acknowledge-no-backuplets it proceed;Disabling
moveGatefails them.Full required checks at 02e5c57, on Major because every K host was busy:
go mod tidy -diff, gofmt,go vet(with and withoute2e,goolm),go test -race ./..., notes-check, shellcheck. All exit 0. Both upgrade tests PASS on kit v4. Earlier (at 3b89e5a): actionlint,make workflow-lint, mdbook. This head touches no workflows.Not checked
TestKubernetesKyMessagewas not run locally (Docker address pools on Major are nearly exhausted). ItsstackHealthyfix only compiles here; CI'skube-message-applyshard must prove it.TestApply(dumpdemo, now on 18) runs only in CI.Decided for you
--acknowledge-no-backup(your "--yes").You need to: merge only after KyMessage-Server cuts a release containing fe88a59 and the catalog follows it. Decide the CNPG path (board
ky-postgres-18).Detail
docs/guided-setup.md, in the KyMessages "PostgreSQL 18" bullet and in the replicas database section. They cover the nextup, the space needed (about 2× the data), how long the move takes, rollback, and the way back to 18 after a rollback, and the manual clean-up:upgrade-from-17/is safe to remove; removingpgdata/pgdata(17) is separate and ends the way back.files/into the app directory (./pg-upgrade/postgres-17-to-18.sh, bound read-only), because KyQuickStart ships its own template. Kubernetes gets the kit embedded in the binary, as the pod command's argument.TestPostgresKitIsVendoredByteForBytechecks thatscripts/(mode 755) and the catalog copy match kit v4. The kube test checks that the pod's arguments equalscripts/postgres-17-to-18.sh.docs/release-candidate-*.jsonand euro-office's PG16 are untouched.dumpdemomoved to 18 on a fresh volume at/var/lib/postgresql.🤖 Generated with Claude Code