Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ jobs:
- run: make workflow-lint
- run: scripts/check-no-binaries.sh

postgres-upgrade:
# The catalog's PostgreSQL 17 to 18 move on its real renderings: kymessage's Compose file
# and the replicated KyIdentity's database pod, each seeded with the previous catalog.
name: PostgreSQL 17 to 18 upgrade
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # the scripts render the previous catalog from git
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
cache: false
- run: shellcheck scripts/postgres-17-to-18.sh scripts/test-postgres-17-to-18.sh scripts/test-postgres-17-to-18-pod.sh
- run: scripts/test-postgres-17-to-18.sh
- run: scripts/test-postgres-17-to-18-pod.sh

e2e-shard:
# sshd in a container on the runner's Docker socket; deploys the hello fixture. Each kind
# test builds its own cluster, so the suite splits by test name into parallel jobs, balanced
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ jobs:
test (macos-latest, stable)
vulncheck
e2e
PostgreSQL 17 to 18 upgrade
Runner image build & run
run: |
set -euo pipefail
Expand Down
36 changes: 28 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ edge compatibility: `docs/redirect.md`.
typed confirmation, never the app's `vol-<name>` claims. It is
`backup_required` where neither can run (no destination, named volumes, a root app on
Kubernetes); any other upgrade needs an explicit, recorded acknowledgement. The manifest's `upgrade.note` is printed and recorded with it.
`upgrade.move` (Docker only; kymessage's PostgreSQL 17 to 18, owner decision 2026-11-25)
gates on the target, not the versions: while the app's directory holds `from` and lacks `to`,
a deploy is backed up first where `kyquickstart backup` can (one snapshot when the version
change takes one too) and otherwise refuses `ack_required` without `--acknowledge-no-backup`.
The suite's PostgreSQL 17 to 18 kit is `scripts/postgres-17-to-18.sh`, kept byte for byte (kit
v4) in kymessage's `files/pg-upgrade/` and `internal/kube/` (`TestPostgresKitIsVendoredByteForByte`).
Uninstall keeps data and secrets, and on Kubernetes ends only once the app's pods are gone;
Docker deploys, backups and lifecycle steps refuse a Compose project `kyq-<app>` whose
containers another root's directory made (another plan, or this one before its root moved),
Expand Down Expand Up @@ -589,8 +595,10 @@ edge compatibility: `docs/redirect.md`.
one-replica rule still hold for it; Deployment `app-replica` is the other pods, claimless
and rolling; the Service selects both by `ky.serves`. The database is the operator's
(`database_secret`: a labelled Secret in `kyq-kyidentity`, key `url`, never a `kyq-` name,
never read into state or output) or Deployment `database`, one Postgres pod on `vol-database`
that only the app's pods reach, where KyIdentity's role is not a superuser. Secret
never read into state or output) or Deployment `database`, one PostgreSQL 18 pod on
`vol-database` that only the app's pods reach, where KyIdentity's role is not a superuser. Its
init container `postgres-17-dump` (17 image) dumps an earlier release's 17 data (`private/pgdata`)
once, and the kit restores it into `private/18/docker` beside it; the 17 data is never written. Secret
`kyq-replica-keys` (the four keys, generated by a single instance of the app's image on
memory, and the bootstrap password) and `kyq-database` are written once and never replaced.
`KYIDENTITY_RECOVERY_KEY_ID` comes only from the plan's owner-confirmed `recovery_key_id`.
Expand All @@ -605,9 +613,10 @@ edge compatibility: `docs/redirect.md`.
`database_instances: 3-5` beside `replicas`, never with `database_secret`, replaces
Deployment `database` with a CloudNativePG `Cluster` of that name (`postgresql.cnpg.io/v1`,
written through the dynamic client with strict field validation): the catalog's
`replicas.cluster_image` (a CloudNativePG operand image), required anti-affinity by node,
synchronous replication `ANY 1`, the same UTF8/C database and non-superuser owner, taken
from `kyq-database` (basic-auth here: `username`, `password`, `url`). The operator is the
`replicas.cluster_image` (a CloudNativePG operand image; PostgreSQL 17, since the installer
has no backup of a Cluster to take before CloudNativePG's major upgrade), required
anti-affinity by node, synchronous replication `ANY 1`, the same UTF8/C database and
non-superuser owner, taken from `kyq-database` (basic-auth here: `username`, `password`, `url`). The operator is the
catalog's `cloudnative-pg` (next) or the cluster owner's: `DatabaseOperatorCheck` (preflight
of a plan that does not install it, and apply's own error) refuses without it, and `Needs.DatabaseCluster` adds the `clusters` permission only
to such a plan. KyIdentity connects to `database-rw` with `sslmode=verify-full` against the
Expand Down Expand Up @@ -664,9 +673,12 @@ edge compatibility: `docs/redirect.md`.
`ports:` entry starts with `{{forward…}}`, `{{forward_addr}}`, `{{media_address}}`,
`{{smtp_address}}` (a `receiver` rendering's alone) or `127.0.0.1`: no bare or wildcard
publication. Files in an app's catalog `files/` are written mode 0644 by deploy where its
Compose file binds them inside a bind directory, and are part of the deploy's input. A service in a Compose profile is a one-shot run
(`compose run --rm`), never part of `up` or health; a bind source inside a bind directory
must exist before deploy starts the app.
Compose file binds them inside a bind directory (a mail app's in its receiver rendering
only), and are part of the deploy's input. A service in a Compose profile is a one-shot run
(`compose run --rm`), never part of `up` or health. A service another waits for with
`service_completed_successfully` (`Once`, `restart: "no"`; kymessage's `postgres-17-dump`)
runs to completion in every `up`, carries the managed labels and is never asked to be running
or healthy. A bind source inside a bind directory must exist before deploy starts the app.
Compose runs with `KYQ_UID`/`KYQ_GID` set to the target user's; `./<name>` bind directories
are created private by the driver before Compose, and no other relative bind source is
accepted. KyMessages' Synapse sets `PYTHONPATH=/config` to load matrix-init's
Expand Down Expand Up @@ -722,6 +734,14 @@ calls and kind nodes must carry their own explicit bounds.
`FuzzStartRequest` (`internal/runner`). CI's `test (ubuntu-latest, stable)` leg runs each for a
fixed execution count after `make ci`; a crasher found later goes under the package's
`testdata/fuzz/<Target>/`.
- CI's `PostgreSQL 17 to 18 upgrade` job (in `release-image.yml`'s REQUIRED list):
`scripts/test-postgres-17-to-18.sh` seeds a 17 install from the previous catalog's rendered
kymessage Compose file and moves it with this one (`up -d` over the running 17, a refused dump
beside a live 17, passwords over the network, rollback, a refused return to 18 after 17 ran and
the documented move-again and keep-18 ways out, rerun, a bad dump, a fresh install, a 17 backup
restored with the manifest's command); `scripts/test-postgres-17-to-18-pod.sh` runs the previous
and current database pod specs in Docker as a kubelet would, with the same rollback cases (not
Kubernetes itself).
- `make workflow-lint`: needs Docker (CI runs it in `vulncheck`); actionlint v1.7.12 on every
workflow and offline, digest-pinned zizmor (medium and up) on `release-image.yml` and
`dependency-release.yml`.
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ state directory, target data and target-held credentials; do not reset them as a

## Unreleased

- PostgreSQL 18 for KyMessages' Matrix stack (Docker) and the replicated KyIdentity's database
pod (Kubernetes), with an automatic dump and restore from 17 that keeps the 17 data.
**Upgrade impact:** a KyMessages install still on 17 is backed up first when its target has
a backup destination; without one, `apply`/`upgrade` needs `--acknowledge-no-backup`. Chat or
KyIdentity sign-in is down while the restore runs; the app's disk needs about twice the 17
data free. Removing the 17 data afterwards is a manual step (`docs/guided-setup.md`). After a
rollback that ran 17, deploying 18 again refuses until you choose to move 17 again or keep 18
(same doc). A one-shot service that fails (the 17 dump) fails `apply`, `start` and health at
once, with its logs. CloudNativePG clusters stay on 17.
- Follow KyPost, KyCalendar and KyYard `0.6.1.1` with verified release image digests.
KyPost includes the receiving accelerator and file-lock/fsync fixes; KyCalendar and
KyYard refresh their Alpine base. **Upgrade impact:** the selected apps restart on
Expand Down
2 changes: 1 addition & 1 deletion cmd/kyquickstart/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestReleaseWorkflow(t *testing.T) {
}
}
}
for _, job := range []string{"test (ubuntu-latest, 1.26.x)", "test (macos-latest, stable)", "vulncheck", "e2e", "Runner image build & run"} {
for _, job := range []string{"test (ubuntu-latest, 1.26.x)", "test (macos-latest, stable)", "vulncheck", "e2e", "Runner image build & run", "PostgreSQL 17 to 18 upgrade"} {
if !slices.Contains(strings.Split(required, "\n"), job) {
t.Errorf("publish's REQUIRED list lacks %q", job)
}
Expand Down
67 changes: 59 additions & 8 deletions docs/guided-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ In namespace `kyq-kyidentity`, Pod Security `restricted`:

### The database

**The installer's (default).** Deployment `database`: one Postgres 17 pod on claim
**The installer's (default).** Deployment `database`: one PostgreSQL 18 pod on claim
`vol-database` (2 GiB), created UTF8 with the C locale as KyIdentity requires. KyIdentity
connects as a role that owns its database and is not a superuser. Only KyIdentity's pods can
reach it, and it can reach nothing. Read this before choosing it:
Expand All @@ -806,8 +806,27 @@ reach it, and it can reach nothing. Read this before choosing it:
- **The connection is not encrypted.** It stays inside the cluster, between the pods the
network policy names; a cluster whose network you do not trust needs your own Postgres with
TLS.
- **The installer does not back it up** and does not upgrade it. KyIdentity's own backups
(below) are its only backup.
- **The installer does not back it up.** KyIdentity's own backups (below) are its only backup.
- **PostgreSQL 17 to 18.** A pod made by an earlier release ran 17 with its data in
`pgdata/` of the claim. The first apply of this release moves it on the same claim: init
container `postgres-17-dump` (the 17 image) dumps `pgdata/` once into `upgrade-from-17/`,
and the 18 container restores that dump into `18/docker` beside it before it starts, roles
and passwords included. The 17 data is only read. The claim needs about twice the 17 data
free; with less, the dump refuses, writes nothing and the pod stays in its init container
until the claim grows (`kubectl -n kyq-kyidentity logs deploy/database -c
postgres-17-dump`). A dump refuses too while `pgdata/postmaster.pid` exists, which only a 17
that crashed leaves: start the previous release's pod once and let it stop. KyIdentity cannot
sign anyone in while the move runs, about as long as a restore of its data. To go back, apply
with the previous release: its 17 pod starts on the untouched `pgdata/`. Applying this
release again after 17 has run refuses: 18 lacks what 17 wrote since, so the dump stops the
pod in its init container, and the apply's health wait ends with the dump's message. Your
choice, from a debug pod mounting the claim, with the database scaled to 0: to move 17 again,
rename `18/` (and `upgrade-from-17/`, if it is there) with a suffix such as `.replaced`
(nothing is deleted); to keep 18 as it was, delete `18/moved-from-17.checkpoint`. Then apply
again. Once the move is done you may delete `upgrade-from-17/` (the dump) from the claim, for
example from a debug pod mounting it; 18 keeps starting. Deleting `pgdata/` (17) is separate,
and ends the way back. Nothing does either for you. No pre-upgrade backup is taken: there is
none of this database (above), and the 17 data stays as the way back.

**The installer's, highly available (`database_instances`).** Owner amendment, 2026-11-13.
`database_instances: 3` (3 to 5) replaces that one pod with a
Expand Down Expand Up @@ -848,7 +867,8 @@ The first apply takes several minutes: the instances start one after another, ea
the one before, and KyIdentity's pods start once all are ready (15 minutes at most, then
apply stops and names the `kubectl describe` to read). The installer still does not back the
database up: KyIdentity's own backups (below) are its only backup. It does not upgrade
Postgres across major versions.
Postgres across major versions: a `Cluster` stays on PostgreSQL 17 (17.12), supported until
November 2029, until the installer has a backup of it to take first.

### The CloudNativePG operator

Expand Down Expand Up @@ -2394,14 +2414,45 @@ integrations:
secret, taken while the stack runs. Restore starts Postgres, loads the dump (without the dump's
`DROP ROLE`/`CREATE ROLE postgres`, which Postgres refuses for the role restoring it), starts
MAS and the console, replays KyIdentity's removals (`replay_after: app`), and only then starts
Synapse, Element and LiveKit.
Synapse, Element and LiveKit. A dump of PostgreSQL 17 restores on 18.
- **PostgreSQL 18.** The stack's Postgres is 18, with its data in `pgdata/18/docker` of the app's
directory. An install made by an earlier release (17, data in `pgdata/pgdata`) moves on the
next `apply`, `install` or `upgrade` that deploys it, whatever the versions:
- **Backup first.** With a backup destination on the target, a `kyquickstart backup`
snapshot is taken before anything changes (step `kymessage.pre-upgrade-backup`); if it
fails, nothing is deployed. Without a destination the command refuses (`ack_required`) until
you pass `--acknowledge-no-backup`; the 17 data is kept either way.
- **The move.** Compose stops the 17 Postgres, the one-shot `postgres-17-dump` (the 17 image,
no network) dumps `pgdata/pgdata` once into `pgdata/upgrade-from-17`, and Postgres restores
it into `pgdata/18/docker` before it starts, roles and passwords included. The suite's
script that does both is `pg-upgrade/postgres-17-to-18.sh` (`scripts/postgres-17-to-18.sh`).
The 17 data is only read. Chat is down while it runs, about as long as a restore of the
backup's dump; past the app's 10-minute health wait apply fails, and a rerun waits again
while the restore finishes.
- **Space.** About twice the 17 data free on the app's disk; with less, the one-shot refuses,
writes nothing, and the stack does not start until there is room. It refuses too while
`pgdata/pgdata/postmaster.pid` exists, which only a crashed 17 leaves: start the previous
release once and stop it cleanly.
- **Going back.** Deploy the previous release (or restore the pre-upgrade snapshot): its 17
starts on the untouched `pgdata/pgdata`.
- **Back to 18 after that.** Once 17 has run, the next deploy of this release refuses: 18
lacks what 17 wrote since, so `postgres-17-dump` exits with that message, which apply
shows, and PostgreSQL does not start. Your choice, as the target user in the app's
directory with the stack stopped: to move 17 again, rename `pgdata/18` (and
`pgdata/upgrade-from-17`, if it is there) with a suffix such as `.replaced` (nothing is
deleted); to keep 18 as it was, delete `pgdata/18/moved-from-17.checkpoint`. Then deploy
again.
- **Clean-up, your choice**, in the app's directory as the target user. `rm -r
pgdata/upgrade-from-17` (the dump) is safe once the move is done; 18 keeps starting, and a
later return from 17 is still refused as above. `rm -r pgdata/pgdata` (17, and any
`.replaced` copies) is separate, and ends the way back. Nothing removes them for you.

### KyMessages: provenance, measurements and residuals

- **Images.** The console image is KyMessage v0.4.4's, attested by `Busnes-app/KyMessage-Server`
`release-image.yml@refs/tags/v0.4.4` from commit `b0f2001e`. The five Matrix images are the
stock upstream builds KyMessage's `docker-compose.matrix.yml` pins by digest; no attestation
was found for them.
`release-image.yml@refs/tags/v0.4.4` from commit `b0f2001e`. The Matrix images, PostgreSQL 18
and the 17 dump one-shot are the stock upstream builds KyMessage's `docker-compose.matrix.yml`
pins by digest; no attestation was found for them.
- **Measured in the end-to-end test.** A chat-only person was locked 0-3 s after their sign-in.
Offboarding refused the open session and its refresh token 0.6-2.6 s after the disable, for
the owner's everyday account and for a person added later. Removing "KyMessages chat" alone
Expand Down
7 changes: 5 additions & 2 deletions internal/catalog/apps/kyidentity/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ version: 0.6.1
# catalog-follow: v0.6.1 attested by Busnes-app/KyIdentity-server release-image.yml@refs/tags/v0.6.1
images:
kyidentity: ghcr.io/busnes-app/kyidentity-server:0.6.1@sha256:270a4b3223b7753b2e3bd2eb8895a3c73c3e9469b4f6333991ca2fa1944c3b65
# Kubernetes, with replicas and no database_secret in the plan: the Postgres they share.
postgres: postgres:17.6-alpine@sha256:ef257d85f76e48da1c64832459b59fcaba1a4dac97bf5d7450c77753542eee94
# Kubernetes, with replicas and no database_secret in the plan: the Postgres they share,
# and the 17 its init container runs once to dump a 17 database for 18 to restore.
postgres: postgres:18.7-alpine3.24@sha256:0115267ab5a509022df9319c77be365cef335adb71556c75f60f5360ee247e71
postgres_17: postgres:17.12-alpine3.24@sha256:f9cf3e1f0066f0eb0c48707d864f0ac5941e9ff454a072077d97a4d278d07d73
# The same, with database_instances in the plan: the CloudNativePG community's Postgres 17
# operand image (17.12 on Debian trixie, no extras), which the cluster's operator runs.
postgres_cluster: ghcr.io/cloudnative-pg/postgresql:17.12-minimal-trixie@sha256:4ae89311e5031155a139a5c6d31a80f6deb135443711e61ff7df41cb549fdcaa
Expand Down Expand Up @@ -68,5 +70,6 @@ kubernetes:
replicas:
since: 0.6.0.2
database_image: postgres
dump_image: postgres_17
database_size: 2Gi
cluster_image: postgres_cluster
Loading
Loading