Roll back the database and /data with a failed update
Before an update, coreapps dumps the app's database (pg_dump or mariadb-dump, in the database's container) and makes a reflink copy of /data (Cores' /federated is btrfs). A failed update restores both before starting the old version; a failed dump refuses the update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,14 @@ What we learned provisioning (2026-12-02/03):
|
||||
|
||||
- [ ] The Core shows as Active in the dashboard
|
||||
- [ ] Tell Federated (2026-12-03):
|
||||
- `upgrade`'s snapshot before each app update mounts `/dev/sda4`
|
||||
(also `bin/btrfs-snapshot`). In coreapp-dev's VM the disk is virtio,
|
||||
`/dev/vda4`, so the mount fails and it sends a Matrix alert to
|
||||
Federated's room for every app it updates. Finding the device with
|
||||
`findmnt -no SOURCE /federated` would work on both. (Or the VM's
|
||||
disk could be SCSI, so it's `/dev/sda` as on their servers.)
|
||||
- `lib/functions.sh` has the Matrix alerts' access token in it, so
|
||||
every Core (and anyone who can read the Core repo) has it
|
||||
- Apps send mail as `fcore` (an `inetOrgPerson` in the `admins` group)
|
||||
with the Core's admin password (`MAIL_PASSWORD=$ADMINPASS` in e.g.
|
||||
`lib/bookstack.sh`), so every app holds the admin password. The
|
||||
@@ -344,15 +352,29 @@ Steps:
|
||||
Authelia, for admins only
|
||||
|
||||
Later:
|
||||
- Done 2026-12-03: a failed update rolls back. coreapps keeps copies of
|
||||
`services/<name>/`, `.env` and `docker-compose.yml`; if anything fails
|
||||
until the app answers (or on Ctrl-C), it runs the teardown of needs the
|
||||
update added, puts the copies back, starts the old version and removes
|
||||
the new image. Data (`/data`, database contents) isn't rolled back: a new
|
||||
version that migrated its database can leave the old one unable to run.
|
||||
Tested on dev.fedcom.net
|
||||
- [ ] Back up the app's database (and `/data`?) before an update, to roll
|
||||
back data too; or a `coreapps rollback` that restores it on request
|
||||
- Done 2026-12-03: a failed update rolls back. Before updating, coreapps
|
||||
keeps, in `/federated/apps/.coreapps-rollback-<name>-*/` (mode 700; not
|
||||
`/tmp`, which is in memory on a Core): `services/<name>/`, `.env`,
|
||||
`docker-compose.yml`, a dump of its database (`pg_dump -Fc`, or
|
||||
`mariadb-dump --single-transaction`, run in the database's container),
|
||||
and a reflink copy of `/data` (`cp --reflink=always`: instant on btrfs,
|
||||
as dev.fedcom.net's `/federated` is; where it can't, no copy, and the
|
||||
messages say `/data` isn't rolled back). A dump that fails refuses the
|
||||
update. If anything fails until the app answers (or on Ctrl-C), it stops
|
||||
the new container, runs the teardown of needs the update added, restores
|
||||
the database (drop, create, restore) and `/data`, puts the files back,
|
||||
starts the old version and removes the new image. The folder is deleted
|
||||
either way. Tested on dev.fedcom.net, with postgres and with mysql: data
|
||||
changed while the failed version ran is back as before
|
||||
- Cores' filesystem (checked 2026-12-03 on the VM, which runs
|
||||
Federated's own Core image): `/` and `/federated` are btrfs, `/federated`
|
||||
a subvolume of its own (`/dev/vda4`, `subvol=/federated`). Federated
|
||||
relies on it: `upgrade` takes a read-only snapshot
|
||||
`federated-before-<app>-<version>` of the whole subvolume before
|
||||
updating each of its apps (`lib/functions.sh`), and `bin/btrfs-snapshot`,
|
||||
`restore-btrfs-snapshot` and `free-up-space -s` manage snapshots. So
|
||||
`/data`'s reflink copy works on every Core
|
||||
- [ ] Large databases: the dump takes time and disk on every update
|
||||
- [ ] Uninstalling a need without removing the app (now refused)
|
||||
- [ ] `bin/start` / `bin/stop` don't know coreapps' apps (see "Tell
|
||||
Federated"); `restart: always` covers reboots
|
||||
|
||||
Reference in New Issue
Block a user