ADFA-5339 feat(dashboard): rebuild-log endpoint, opt-in website refresh (server half) - #516
Merged
Merged
Conversation
…ocalhost-only endpoints that
the UI surfaces (Update⇄Rebuild button, expandable Details, the confirm-dialog checkbox) will build
on in their own PRs. Nothing user-facing here; verifiable entirely by `curl`.
dash-node serves two separate artifacts from one process: the **REST core** (`static/dashboard/`,
has a `package.json` version) and the **landing site** (`static/site/`, no version of its own). The
version belongs strictly to the core; the site never carries one. This PR honours that by
construction — `site-updater.sh` touches neither `package.json` nor the reported version, so the
core can never present a "site version".
- **`GET /system/dashboard/rebuild/log`** — read-only tail of `/var/log/dash-rebuild.log` (last
~200 lines; a whole rebuild fits, so the client replaces the panel each poll rather than tracking
a cursor). No rebuild ever ran = empty log, not an error.
- **`POST /system/dashboard/rebuild` accepts `{ site: true }`** → passes `K2GO_SITE=1` to the
script; the response echoes `site`. Absent/false keeps the previous behaviour exactly.
- **`rebuild-dashboard.sh`** runs `site-updater.sh` in **finalize** — from the same clone the
rebuild's `git fetch+reset` just refreshed, and only **after** the core swap has verified live, so
the deployed site matches the new source. It is **best-effort**: a site failure is logged, never a
rollback of the already-verified core update. Runs on any rebuild (Update or a same-version
Rebuild), which is why the site action is versionless and idempotent.
Lifecycle worth stating: the site deploys **only if the core reached finalize**. If the staging
build or smoke test fails, finalize is never reached and the site is untouched — it matches the new
source or is not deployed, never half.
dash-node **1.2.11 → 1.2.12** (both changes are REST-facing; CHANGELOG updated).
- Shell syntax checked (`sh -n` / `bash -n`) on both scripts.
- TypeScript reviewed by hand; **not** typechecked here (no Node on the build machine) — the
deploy's `yarn build` (= `tsc`) is the real gate, same as ADFA-5361.
- On device, after deploying this branch:
site-updater.sh mirrors static/site into the served home dir, but it wiped the destination BEFORE checking the source — so a mis-resolved SITE_SRC (what the sh-vs-bash bug produced: /root) deleted the served site and copied the wrong tree with no rollback. The `[ -d ]` guard was too weak: a wrong-but-existing dir passes it. Replaced with `[ -f "$SITE_SRC/index.html" ]`, which only the real site satisfies — one stronger guard instead of two, and it refuses (printing why, changing nothing) instead of destroying on a bad source. Device-caught while verifying ADFA-5339.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 server half of the Dashboard-update card. Two additive, localhost-only endpoints the app
UI will build on (in a separate PR), plus two robustness fixes that device verification surfaced.
No user-facing change here; verified end-to-end by
curlon device (dash-node 1.2.11 → 1.2.12).Touches only
static/dashboard/+tools/— nocontroller/app/, so it can't conflict with theapp PRs.
Endpoints
GET /system/dashboard/rebuild/log— read-only tail of/var/log/dash-rebuild.log(last ~200lines; a whole rebuild fits). No rebuild yet = empty log, not an error. Feeds the card's Details.
POST /system/dashboard/rebuildaccepts{ site: true }→ refreshes the served landing page inthe same run via
site-updater.sh, from the same clone the rebuild'sgit fetch+resetrefreshes,in finalize after the core swap verifies live, so the site matches the new source.
Semantics (per the ticket's "read first")
The REST core and the landing site are separate artifacts. The version belongs to the core; the site
never carries one. Enforced by construction:
site-updater.shtouches neitherpackage.jsonnor thereported version, and a site failure is logged, never a rollback of the already-verified core update.
Verified on device: after a
site:truerebuild,system/versionwas unchanged and/home/servedthe fresh landing page.
Two fixes device verification caught
sh→bashfor site-updater (rebuild-dashboard.sh). It's a bash script (${BASH_SOURCE[0]},arrays); invoking it with
sh(dash) tripped on the bash-isms and mis-resolved its own source dir to/root. The best-effort guard had contained it — the core stayed 1.2.12 — but the site step failed.site-updater.sh). The mirror wiped theserved dir before checking the source, so the mis-resolved
/rootdeleted the site and copied thewrong tree with no rollback. The
[ -d ]guard was too weak (a wrong-but-existing dir passes);replaced with
[ -f "$SITE_SRC/index.html" ], which only the real site satisfies — one strongerguard instead of two, refusing (changing nothing) on a bad source.
Deploy note
Because
rebuild-dashboard.shself-updates viagit reset, a box needs the rebuild run twice topick up these script changes: the first run executes the pre-fix script in memory while fetching the
new one; the second runs the new one.
dash-node 1.2.11 → 1.2.12.