Update rehearsal: downgrade check for deploys, -N versions, failed logs

coreapp deploy refuses a lower version than the installed one without
--downgrade, as coreapp install does. Versions with -N (the Coreapp's own
fix on the same upstream version) order after the upstream one, for
releases too. A failed start keeps the container's whole log, from its
first start, in <name>-failed-start.log. coreapp status shows the
installed version beside the folder's.

Skill: references/updating.md (versions, what to check between versions,
testing an update over real data and its rollback, no copy after a
successful update); reading the installer's bash -x log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 14:06:31 -07:00
co-authored by Claude Opus 5.5
parent 491af8745f
commit 0aa334d22a
8 changed files with 168 additions and 18 deletions
+25
View File
@@ -587,6 +587,31 @@ Steps:
- [ ] David: sign in to listmonk-app as admin@dev.fedcom.net - [ ] David: sign in to listmonk-app as admin@dev.fedcom.net
(Super Admin, Settings), and send a campaign from (Super Admin, Settings), and send a campaign from
`listmonk-app@dev.fedcom.net`; remove it when done `listmonk-app@dev.fedcom.net`; remove it when done
- Rehearsed 2026-12-04, updating an app in use: a copy of the
listmonk port as `listmonk-upd` on 5.1.0 with real data (lists,
subscribers, a draft campaign, changed settings, an upload, a
sign-in), updated to 6.2.0 (three upstream migrations, one that
hashes API tokens for good): data, settings, sessions and sign-in
came through, and an update made to fail after migrating rolled
back to 5.1.0 exactly. Deployed at
`https://listmonk-upd.dev.fedcom.net/`. Fixed from it: `coreapp
deploy` from a folder refuses a lower `version` without
`--downgrade` (as `coreapp install` does); versions with `-N`
(`6.2.0-1`, the Coreapp's own fix) order after the upstream one,
for releases too; a failed start keeps the container's whole log
(`<name>-failed-start.log`; the printed end missed the first
start, where the migrations ran); `coreapp status` shows the
installed version beside the folder's. Skill: references/
updating.md (versions, what to check between versions, testing an
update over real data and its rollback, no copy after a
successful update), reading the installer's `bash -x` log
- [ ] Decide: keep the last pre-update database copy (and `/data`
snapshot) after a successful update, until the next one, so a
Core owner can go back days later (`coreapps restore <name>`)?
Today it's deleted once the new version answers; it costs the
database's size on disk per app
- [ ] David: sign in to listmonk-upd as admin@dev.fedcom.net
(settings page, visual editor on 6.2.0); remove it when done
- Rehearsed 2026-12-04 with a new app from scratch, Lending Shelf - Rehearsed 2026-12-04 with a new app from scratch, Lending Shelf
(`coreapp new --postgres --sso --email`; Python, postgres, sso, (`coreapp new --postgres --sso --email`; Python, postgres, sso,
email): deployed at `https://lending-shelf.dev.fedcom.net/`, Core email): deployed at `https://lending-shelf.dev.fedcom.net/`, Core
+1 -1
View File
@@ -90,7 +90,7 @@ each new app explains the files and the settings it gets.
| `coreapp new --postgres --sso <name>` | Both: a database and sign-in (the example counts each person's visits) | | `coreapp new --postgres --sso <name>` | Both: a database and sign-in (the example counts each person's visits) |
| `coreapp new --mysql <name>` | (Instead of `--postgres`, with no example app.) Its own database on the Core's MariaDB | | `coreapp new --mysql <name>` | (Instead of `--postgres`, with no example app.) Its own database on the Core's MariaDB |
| `coreapp new --email <name>` | (With any of the above.) Sending mail through the Core's mail server, with the app's own account | | `coreapp new --email <name>` | (With any of the above.) Sending mail through the Core's mail server, with the app's own account |
| `coreapp deploy [--recreate] [--drop-database]` | Build its image, copy it to the Core over SSH, install it, or update it keeping its settings and data; a failed update rolls back to the version before (`--recreate`: a fresh container even if nothing changed). Needs added to `coreapp.toml` are set up; needs taken out are removed once the new version works, and taking out `postgres` or `mysql` (deleting the database) needs `--drop-database`, which asks you to type the app's name | | `coreapp deploy [--recreate] [--drop-database] [--downgrade]` | Build its image, copy it to the Core over SSH, install it, or update it keeping its settings and data; a failed update rolls back to the version before (`--recreate`: a fresh container even if nothing changed). Needs added to `coreapp.toml` are set up; needs taken out are removed once the new version works, and taking out `postgres` or `mysql` (deleting the database) needs `--drop-database`, which asks you to type the app's name. A lower `version` than the installed one is refused without `--downgrade`, since an older version may not understand the newer one's data |
| `coreapp check` | It answers at `https://<name>.<domain><health>` with a valid certificate | | `coreapp check` | It answers at `https://<name>.<domain><health>` with a valid certificate |
| `coreapp core` | What the Core in the VM offers apps: PostgreSQL (and which extensions an app can enable), MariaDB, Authelia, the mail server and Traefik with their versions, Docker, and the machine | | `coreapp core` | What the Core in the VM offers apps: PostgreSQL (and which extensions an app can enable), MariaDB, Authelia, the mail server and Traefik with their versions, Docker, and the machine |
| `coreapp mail` | What the Core's mail server did with the mail the app sent in the last day: accepted from its account, then delivered, deferred or bounced, with the reason (apps with `email`) | | `coreapp mail` | What the Core's mail server did with the mail the app sent in the last day: accepted from its account, then delivered, deferred or bounced, with the reason (apps with `email`) |
+10
View File
@@ -258,6 +258,16 @@ The Core's own scripts trace secrets, so their output goes to
deploys; breaking it again in an update gives the same message with deploys; breaking it again in an update gives the same message with
the wget error, rolls back, and right after "Rolled back" the public the wget error, rolls back, and right after "Rolled back" the public
address answers 200 (the rollback waits for traefik). address answers 200 (the rollback waits for traefik).
5i. Versions from a folder: with `6.2.0` installed, deploying `6.1.9` is
refused before building ("has version 6.2.0 installed; 6.1.9 is
older ... add --downgrade"); `coreapp deploy --downgrade` deploys it;
`6.2.0-1` and the same `6.2.0` deploy without asking. Releases order
`v1.2.0` < `v1.2.0-2` < `v1.10.0`. `coreapp status` shows "This
folder: ..." and "Installed version: 6.2.0" from the Core.
5j. A container that fails to start (prints a line and exits): deploy
prints the end of its log and "Its whole log, from its first start:
/federated/logs/coreapps/<name>-failed-start.log", which has every
restart's lines with timestamps; the same after an unhealthy check.
5g. A slow start (`coreapp new slowtest`, with `CMD` sleeping 40 s, 5g. A slow start (`coreapp new slowtest`, with `CMD` sleeping 40 s,
logging "migrating", before the server): deploy prints "still starting logging "migrating", before the server): deploy prints "still starting
(31 s); its log: migrating", then "Installed". A container that exits (31 s); its log: migrating", then "Installed". A container that exits
+8 -6
View File
@@ -6,7 +6,7 @@
# coreapp new [--postgres | --mysql] [--sso] [--email] <name> # coreapp new [--postgres | --mysql] [--sso] [--email] <name>
# make a new app in ./<name> (with its own database, # make a new app in ./<name> (with its own database,
# sign-in through the Core's Authelia, sending mail) # sign-in through the Core's Authelia, sending mail)
# coreapp deploy [--recreate] [--drop-database] # coreapp deploy [--recreate] [--drop-database] [--downgrade]
# build, copy to the Core, install or update # build, copy to the Core, install or update
# (--recreate: a new container even if nothing # (--recreate: a new container even if nothing
# changed; --drop-database: allow dropping # changed; --drop-database: allow dropping
@@ -248,12 +248,13 @@ cmd_new() {
# --- deploy ----------------------------------------------------------------- # --- deploy -----------------------------------------------------------------
cmd_deploy() { cmd_deploy() {
local plan state tier answer local_id core_id dropped addon="" recreate="" dropdb="" local plan state tier answer local_id core_id dropped addon="" recreate="" dropdb="" downgrade=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--recreate) recreate=--recreate ;; --recreate) recreate=--recreate ;;
--drop-database) dropdb=--drop-database ;; --drop-database) dropdb=--drop-database ;;
*) die "Usage: coreapp deploy [--recreate] [--drop-database]" ;; --downgrade) downgrade=--downgrade ;;
*) die "Usage: coreapp deploy [--recreate] [--drop-database] [--downgrade]" ;;
esac esac
shift shift
done done
@@ -264,7 +265,7 @@ cmd_deploy() {
echo "Updating the installer on the Core ($REMOTE_INSTALLER)..." echo "Updating the installer on the Core ($REMOTE_INSTALLER)..."
sync_installer sync_installer
# What installing would do (and whether the Core refuses it: name taken...) # What installing would do (and whether the Core refuses it: name taken...)
plan="$(installer plan $dropdb)" || exit 1 plan="$(installer plan $dropdb $downgrade)" || exit 1
state="$(sed -n 's/^state=//p' <<< "$plan")" state="$(sed -n 's/^state=//p' <<< "$plan")"
tier="$(sed -n 's/^tier=//p' <<< "$plan")" tier="$(sed -n 's/^tier=//p' <<< "$plan")"
dropped="$(sed -n 's/^dropped_needs=//p' <<< "$plan")" dropped="$(sed -n 's/^dropped_needs=//p' <<< "$plan")"
@@ -301,7 +302,7 @@ cmd_deploy() {
# Install, or update (which recreates the container if the image changed, # Install, or update (which recreates the container if the image changed,
# even under the same version) # even under the same version)
installer install $addon $recreate $dropdb || exit 1 installer install $addon $recreate $dropdb $downgrade || exit 1
[[ "$state" == new ]] && echo "(coreapp check tests it at its public address, as people reach it.)" [[ "$state" == new ]] && echo "(coreapp check tests it at its public address, as people reach it.)"
return 0 return 0
} }
@@ -343,7 +344,8 @@ cmd_status() {
local address local address
core "docker ps -a --filter name='^$NAME\$' --format 'Container: {{.Names}} {{.Status}} image {{.Image}}' core "docker ps -a --filter name='^$NAME\$' --format 'Container: {{.Names}} {{.Status}} image {{.Image}}'
[ -n \"\$(docker ps -aq --filter name='^$NAME\$')\" ] || echo 'Not installed on the Core.'" [ -n \"\$(docker ps -aq --filter name='^$NAME\$')\" ] || echo 'Not installed on the Core.'"
echo "App: $TITLE $(image)" echo "This folder: $TITLE $(image)"
echo "Installed version: $(core "sed -n 's/^IMAGE_VERSION=//p' /federated/apps/$NAME/.env 2> /dev/null || true")"
address="$(core "sed -n 's/^INTERNAL_IP=//p' /federated/services/$NAME/service 2> /dev/null || true")" address="$(core "sed -n 's/^INTERNAL_IP=//p' /federated/services/$NAME/service 2> /dev/null || true")"
[[ -z "$address" ]] || echo "Address on the Core: $address, port $PORT" [[ -z "$address" ]] || echo "Address on the Core: $address, port $PORT"
echo "Needs: ${NEEDS:-nothing}" echo "Needs: ${NEEDS:-nothing}"
+38 -4
View File
@@ -504,12 +504,25 @@ def normalize_url(url):
return f"{scheme}://{host.lower()}/{path}" return f"{scheme}://{host.lower()}/{path}"
# A release's version: numbers with dots, and a -N for the Coreapp's own
# fixes on the same upstream version (8.8.6-2 comes after 8.8.6)
VERSION_ORDER = r"([0-9]+(?:\.[0-9]+)*)(?:-([0-9]+))?"
def is_release(tag): def is_release(tag):
return bool(re.fullmatch(r"v[0-9]+(?:\.[0-9]+)*", tag or "")) return bool(re.fullmatch("v" + VERSION_ORDER, tag or ""))
def version_order(version):
"""Comparable form of a version like 6.2.0 or 6.2.0-2, else None."""
found = re.fullmatch(VERSION_ORDER, version or "")
if not found:
return None
return [int(part) for part in found.group(1).split(".")], int(found.group(2) or 0)
def version_key(tag): def version_key(tag):
return [int(part) for part in tag[1:].split(".")] return version_order(tag[1:])
def git(args, cwd=None, auth=None): def git(args, cwd=None, auth=None):
@@ -696,6 +709,17 @@ def plan(m, origin=None, downgrade=False, drop_database=False):
"To install it anyway, add --downgrade (if it fails to start, the update " "To install it anyway, add --downgrade (if it fails to start, the update "
"rolls back).") "rolls back).")
p["downgrade_from"] = installed_tag p["downgrade_from"] = installed_tag
# The same from a folder (coreapp deploy), by coreapp.toml's version
installed_version = service_value(f"{APPS}/{name}/.env", "IMAGE_VERSION")
old, new = version_order(installed_version), version_order(m["version"])
if not origin and old and new and new < old:
if not downgrade:
raise Refused(
f"'{name}' has version {installed_version} installed; {m['version']} is "
"older, and may not understand the data the newer version left (its "
"database and /data). To deploy it anyway, add --downgrade (if it fails "
"to start, the update rolls back).")
p["downgrade_from"] = installed_version
else: else:
p["new_needs"] = list(m["needs"]) p["new_needs"] = list(m["needs"])
p["dropped_needs"] = [] p["dropped_needs"] = []
@@ -1485,7 +1509,17 @@ def wait_until_answering(m, p):
sys.stderr.write(logs.stdout + logs.stderr) sys.stderr.write(logs.stdout + logs.stderr)
raise Refused(f"{name} doesn't answer at {url} after " raise Refused(f"{name} doesn't answer at {url} after "
f"{time.monotonic() - started:.0f} s (state: {state or 'missing'}; " f"{time.monotonic() - started:.0f} s (state: {state or 'missing'}; "
"its log is above).") f"the end of its log is above). {keep_failed_log(name)}")
def keep_failed_log(name):
"""The failed container's whole log, every restart (its first start,
which ran the migrations, too), before a rollback removes it."""
path = log_path(name, "failed-start")
with open(path, "w") as out:
subprocess.run(["docker", "logs", "--timestamps", name], stdout=out,
stderr=subprocess.STDOUT)
return f"Its whole log, from its first start: {path} on the Core."
def wait_for_route(m, p): def wait_for_route(m, p):
@@ -1513,7 +1547,7 @@ def wait_for_route(m, p):
return return
health = container_health(m["name"]) health = container_health(m["name"])
if health == "unhealthy": if health == "unhealthy":
raise Refused(unhealthy_message(m, host)) raise Refused(f"{unhealthy_message(m, host)} {keep_failed_log(m['name'])}")
if health != "starting" and time.monotonic() - started > 30: if health != "starting" and time.monotonic() - started > 30:
break break
time.sleep(2) time.sleep(2)
+16 -6
View File
@@ -73,7 +73,7 @@ title = "My App" # shown in the Core's dashboard
description = "What it does, in a sentence" description = "What it does, in a sentence"
docs = "https://example.com/docs" # optional; installed from a repository, defaults to it docs = "https://example.com/docs" # optional; installed from a repository, defaults to it
image = "localhost/coreapp/my-app" # image name; the Core runs image:version image = "localhost/coreapp/my-app" # image name; the Core runs image:version
version = "0.1.0" # the image tag; raise it for each release version = "0.1.0" # the image tag; raise it for each release (6.2.0, then 6.2.0-1)
port = 8080 # the port the app serves HTTP on (any; 8080 is usual) port = 8080 # the port the app serves HTTP on (any; 8080 is usual)
health = "/health" # a path that answers once it's up health = "/health" # a path that answers once it's up
needs = ["postgres", "sso"] # what it needs from the Core, or [] ("mysql", "email" too) needs = ["postgres", "sso"] # what it needs from the Core, or [] ("mysql", "email" too)
@@ -365,6 +365,13 @@ ends by running the upstream one (and written at every start, for settings
the app keeps in its database); waiting for the database and Authelia at the app keeps in its database); waiting for the database and Authelia at
startup; a non-root user; its own `icon.png`; one container. startup; a non-root user; its own `icon.png`; one container.
### 2c. Updating an app (a new upstream version or release)
Read [references/updating.md](references/updating.md) first: versions
(`-N` for the Coreapp's own fixes), what to check between versions,
testing an update over real data and its rollback, and what the Core's
database copy covers.
### 3. Deploy and test ### 3. Deploy and test
```bash ```bash
@@ -407,7 +414,7 @@ parts were tested that way rather than through a real sign-in.
| Command | Shows | | Command | Shows |
|---|---| |---|---|
| `coreapp status` | Its container, address, port, needs, URL, and the Core's PostgreSQL or MariaDB version if it needs one | | `coreapp status` | Its container, the version installed and the folder's, address, port, needs, URL, and the Core's PostgreSQL or MariaDB version if it needs one |
| `coreapp mail` | What the Core's mail server did with the mail it sent (apps with `email`) | | `coreapp mail` | What the Core's mail server did with the mail it sent (apps with `email`) |
| `coreapp inbox [--clear]` | The mail the test account got: the newest 10, with their text (`--clear` empties it) | | `coreapp inbox [--clear]` | The mail the test account got: the newest 10, with their text (`--clear` empties it) |
| `coreapp logs` / `coreapp logs -f` | The app's own log | | `coreapp logs` / `coreapp logs -f` | The app's own log |
@@ -425,9 +432,11 @@ Common causes:
ran before, with its settings, its database and `/data` as they were ran before, with its settings, its database and `/data` as they were
before the update (`/data` only where the Core's filesystem can copy it before the update (`/data` only where the Core's filesystem can copy it
instantly; the message says), and undid needs the update added. Whatever instantly; the message says), and undid needs the update added. Whatever
the failed version wrote is gone. Its log is printed above that line the failed version wrote is gone. The end of its log is printed above
(`coreapp logs` now shows the old version's). When the version wasn't that line, and its whole log, from its first start, is kept on the Core
raised, the image that failed is the one running again. (deploy says where; `coreapp logs` now shows the old version's). When
the version wasn't raised, the image that failed is the one running
again.
- "keeps a copy of its database ... Nothing was changed. Free some space - "keeps a copy of its database ... Nothing was changed. Free some space
first.": before an update the Core copies the app's database, to roll first.": before an update the Core copies the app's database, to roll
back to, and the apps' disk hasn't room for it (it keeps 1 GB free for back to, and the apps' disk hasn't room for it (it keeps 1 GB free for
@@ -455,7 +464,8 @@ Common causes:
The installer's own log (the Core's install scripts) is on the Core in The installer's own log (the Core's install scripts) is on the Core in
`/federated/logs/coreapps/`. It contains secrets, so don't print it in full; `/federated/logs/coreapps/`. It contains secrets, so don't print it in full;
look at the end of it with `coreapp-vm ssh tail -n 40 /federated/logs/coreapps/<name>-install.log` look at the end of it with `coreapp-vm ssh tail -n 40 /federated/logs/coreapps/<name>-install.log`
only when a deploy fails in the installer itself. only when a deploy fails in the installer itself. It's a shell trace
(`bash -x`): look for the last command before the error, not for words.
### 5. Publishing (only when the user asks for a release) ### 5. Publishing (only when the user asks for a release)
+1 -1
View File
@@ -52,4 +52,4 @@ To check a release the way a Core's owner will get it:
publish a new version. publish a new version.
- Going back to an older release needs `coreapp install --downgrade - Going back to an older release needs `coreapp install --downgrade
<url>@v<old>`; the user decides that, since the older version may not <url>@v<old>`; the user decides that, since the older version may not
understand the newer one's data. understand the newer one's data (see references/updating.md).
+69
View File
@@ -0,0 +1,69 @@
# Updating an app: a new upstream version, or a new release of your own
Read this before moving an installed app to a new version (a newer
upstream image, or your own app's next release). SKILL.md has the deploy
and publish commands around it.
## Versions
`version` in `coreapp.toml` is the image's tag and the release's
(`v<version>`). For a port, follow upstream's version (`6.2.0`); for a
release that changes only the Coreapp on the same upstream version (the
entrypoint, a setting), add `-N` (`6.2.0-1`, `6.2.0-2`): the Core orders
`6.2.0` < `6.2.0-1` < `6.2.1`. Raise it for every release; while you're
trying things on your own Core, you don't need to.
A Core refuses an older version than the one it has, unless asked:
`coreapp deploy --downgrade` from a folder, `coreapp install --downgrade`
from a repository. That's for the user to decide: an older version may not
understand what the newer one left in its database and `/data`.
## Before: what changes
- Read upstream's release notes for every version in between (not only
the newest), their upgrade steps and their migrations (in the source:
`migrations/`). Note migrations that can't be undone (data rewritten,
tokens hashed) and slow ones (rebuilt indexes or views on big tables).
- Check what your Coreapp writes still fits: the settings your entrypoint
maps or writes into the database (renamed or moved keys), the upstream
entrypoint and `CMD` your entrypoint ends with, the image's user, ports,
`VOLUME`s and `HEALTHCHECK` (`docker inspect` both images and compare),
and a new minimum database version (`min_version`).
- "Back up the database first", in upstream's steps, is done by the Core:
before every update it copies the app's database (and `/data`, where
its filesystem can do that instantly) and rolls back to that copy if the
new version doesn't start. Upstream's own upgrade command (`--upgrade`,
`migrate`) belongs in the entrypoint, so it runs at every start.
## Testing an update
Test it over an install that has real data, not a fresh one:
1. Deploy the version people run now (a copy under another `name` is
fine), and use it the way people do: content, a changed setting, an
upload, a `coreapp signin`. Commit that as the released version.
2. Record what's there (through the app's API or SQL as its database
user), so you can compare after.
3. Deploy the new version over it and compare: the data, the settings
the Core writes (sign-in and mail still work), sessions, uploads. Sign
in again, and as a brand-new account (`coreapp signin --remove-account`
first): new versions change first sign-in and roles.
4. `coreapp deploy --recreate` once more on the new version.
To see a failed update roll back, deploy a throwaway version (say
`6.2.0-failtest`, not committed) whose entrypoint runs the migrations and
then exits: deploy says "Rolled back", and the old version runs with its
database as before. A throwaway version is needed: when the version isn't
raised, the image that failed is the one running again. The failed
container's whole log, from its first start (where the migrations ran),
is kept on the Core; deploy prints where.
## After: there's no copy to go back to
The Core's copy of the database is only for the update itself: once the
new version answers, it's deleted. If a problem shows up later, the way
forward is a fixed release (`-N`); going back to the older version means
the older version on the newer data (refused without `--downgrade`, and
often broken by migrations it doesn't know), or the Core's own backups,
which are the user's. Say this in your report when an update has
migrations that can't be undone.