diff --git a/deploy/federated/STRATEGY.md b/deploy/federated/STRATEGY.md index 42491b3..a5c3bdc 100644 --- a/deploy/federated/STRATEGY.md +++ b/deploy/federated/STRATEGY.md @@ -318,6 +318,43 @@ Suite-side work items to finish the link (NOT in this repo), copy-paste ready: (automations/assistant); those still resolve per-user BYO first, then the plan-gated `AI_*` server env key. +### Incident 2026-11-03: the auto-upgrader took superbrain down (and the fix) + +`upgrade-federated.timer` (daily ~10:06, runs `/federated/bin/upgrade` with no +args, transcript in `/federated/logs/upgrade.log`) redeployed superbrain +(trigger: the then-new `update-superbrain` branch in the Core repo), removed +all three containers, then restarted via `/federated/bin/start superbrain` — +which fell through to `usage; exit 2` because **superbrain is absent from +`EXTRA_APPS` in `lib/functions.sh`** (the SERVICES registry). `upgrade_app` +ignored the exit status and printed "Done upgrading" over the dead stack; +traefik then answered its default 404 for the whole hostname until manual +recovery (~9 h). Aggravator: the DB ledger was already at 017 (a 1.2.0 migrate +had run during the Nov 2 operator session) while `.env` pinned 1.0.1, so any +restart attempt hit migrate.sh's "applied chain must stay complete" refusal. +Recovery: pinned `IMAGE_VERSION="1.2.0"` + restored the `AI_*` lines, +`compose up -d`. + +Fix layers, outermost first: + +1. **Pin (immediate, house mechanism):** `IMAGE_VERSION_HOLD=1` in + `/federated/apps/superbrain/.env` — `upgrade_app` returns before touching + anything. REMOVE once layer 3 lands and auto-upgrades are wanted again + (until then, upgrades are manual: `/federated/bin/upgrade superbrain`). +2. **erwin-local (defense in depth, live now):** commit `a1eae10` in the + host's `/federated` checkout adds superbrain to `EXTRA_APPS` and makes + `upgrade_app` check the start exit status + container liveness, alerting + via `send_matrix_alert` instead of printing success over a dead stack. + Verified: `/federated/bin/start superbrain` now dispatches ("already + running") instead of usage. **This commit cannot be pushed**: the box's + `installcore` token is pull-only (403) and andrew's account cannot even + read the Core repo — so erwin's suite master sits one commit ahead of + origin. When the maintainer merges the equivalent change, reset erwin's + `/federated` to origin/master to avoid a diverged pull. +3. **Core repo (permanent, all cores):** `core-fix-upgrade-superbrain.patch` + next to this document is `a1eae10` in `git format-patch` form — hand it to + the Core maintainer (the `update-superbrain` branch convention is the + house landing path for suite-side app changes). + ### Not applicable - `email_superbrain`: since the notification engine (2026-10-26) the app diff --git a/deploy/federated/core-fix-upgrade-superbrain.patch b/deploy/federated/core-fix-upgrade-superbrain.patch new file mode 100644 index 0000000..9fb073d --- /dev/null +++ b/deploy/federated/core-fix-upgrade-superbrain.patch @@ -0,0 +1,62 @@ +From a1eae10112af01b9c35130fa69d149427a83a365 Mon Sep 17 00:00:00 2001 +From: andrew +Date: Wed, 4 Nov 2026 15:39:12 +0000 +Subject: [PATCH] Register superbrain in EXTRA_APPS; fail upgrade_app when the + app does not come back up + +The 2026-11-03 upgrade-federated.timer run stopped superbrain, then +/federated/bin/start superbrain fell through to usage/exit 2 because +superbrain was absent from SERVICES (CORE_APPS/EXTRA_APPS); upgrade_app +ignored the exit status and printed Done upgrading over a dead stack, +which left traefik answering its default 404 for the whole hostname. + +- add superbrain to EXTRA_APPS so bin/start can dispatch it +- upgrade_app: after the post-redeploy start, check the exit status AND + that the primary container is actually running; otherwise + send_matrix_alert and return 1 instead of reporting success +--- + lib/functions.sh | 7 ++++++- + services/superbrain/service | 2 +- + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/lib/functions.sh b/lib/functions.sh +index c00c444..9bd2fba 100644 +--- a/lib/functions.sh ++++ b/lib/functions.sh +@@ -31,7 +31,7 @@ + + # Define all services + CORE_APPS=("pdnsmysql" "pdns" "pdnsadmin" "traefik" "postgresql" "ldap" "mail" "authelia") +-EXTRA_APPS=("collabora" "nextcloud" "matrix" "element" "listmonk" "vaultwarden" "panel" "wireguard" "jitsi" "baserow" "gitea" "caddy" "autodiscover" "castopod" "wordpress" "coturn" "bookstack" "freescout" "msp" "espocrm" "nginx" "matrixslack" "matrixsignal" "matrixwhatsapp" "dashboard" "jitsiopenid" "roundcube" "redis" "discourse" "wordpressshop" "plane" "calcom" "headscale" "headplane" "dittofeed" "kimai" "nodeexporter" "tailscale" "gitearunner" "nextcloudtalk" "clickhouseserver" "plausible" "docuseal" "mautic" "matomo" "superpanel" "n8n" "immich" "mcpserver" "erpnext" "hermes") ++EXTRA_APPS=("collabora" "nextcloud" "matrix" "element" "listmonk" "vaultwarden" "panel" "wireguard" "jitsi" "baserow" "gitea" "caddy" "autodiscover" "castopod" "wordpress" "coturn" "bookstack" "freescout" "msp" "espocrm" "nginx" "matrixslack" "matrixsignal" "matrixwhatsapp" "dashboard" "jitsiopenid" "roundcube" "redis" "discourse" "wordpressshop" "plane" "calcom" "headscale" "headplane" "dittofeed" "kimai" "nodeexporter" "tailscale" "gitearunner" "nextcloudtalk" "clickhouseserver" "plausible" "docuseal" "mautic" "matomo" "superpanel" "n8n" "immich" "mcpserver" "erpnext" "hermes" "superbrain") + SERVICES=("${CORE_APPS[@]}" "${EXTRA_APPS[@]}") + + failts() { +@@ -345,6 +345,11 @@ upgrade_app() { + echo -ne "$APP was already shut down so we won't be starting it.\n" + else + /federated/bin/start $APP ++ if [ $? -ne 0 ] && [ "$(docker container inspect -f '{{.State.Running}}' $APP 2>/dev/null)" != "true" ]; then ++ send_matrix_alert "$DOMAIN ($EXTERNALIP): upgrade of $APP to $VERSION finished but the app did not come back up - investigate now, the service is likely DOWN" ++ echo -ne "ERROR: start $APP failed during upgrade - app may be DOWN, not reporting success.\n" ++ return 1 ++ fi + if [ -x "/federated/services/${APP}/upgrade/post" ]; then + if ! /federated/services/${APP}/upgrade/post ${IMAGE_VERSION} ${VERSION}; then + echo "Post-upgrade script for ${APP} failed, verify the app still works" +diff --git a/services/superbrain/service b/services/superbrain/service +index 7ad6015..a6e9b31 100644 +--- a/services/superbrain/service ++++ b/services/superbrain/service +@@ -2,7 +2,7 @@ NAME=Superbrain + DESCRIPTION="Bookmark & Knowledge Base" + DOCS=https://github.com/andrew/superbrain + CONTAINER=federatedcomputer/superbrain-app +-VERSION=1.0.1 ++VERSION=1.2.0 + INTERNAL_IP=192.168.0.93 + DEPENDS="postgresql" + PORTS=3000 +-- +2.53.0 +