feat(engine): render asset trees onto a podman host (config.assets) - #305
Merged
Conversation
Prerequisite for #303. Quadlets alone cannot carry a stack's CONFIGURATION, and the Monitoring stack is mostly configuration: prometheus/snmp/loki/tempo/otel YAML plus Grafana provisioning and dashboards. Before this, a stack needing config files had to ship them by a SECOND mechanism running alongside converge — stacks/monitoring/deploy/install.sh tars the tree into the CT and runs `docker compose up`. Keeping that while quadlets came from converge would mean two deploy paths, two sources of truth and an ordering hazard (a unit can start before its config exists). config: assets: podman-host/assets # dir in the stack repo assetsTarget: /home/podman/monitoring # default /home/<user>/assets Rendered recursively, parents created, `.sh` files land 0755 and everything else 0644, then chowned to the rootless user. Emitted BEFORE units start, so a unit never mounts a config that isn't there yet — asserted by a test. Rendered PER FILE, not as a tarball, deliberately: a tar embeds mtimes, which would change the emitted script on every run and therefore churn the managed marker (which hashes the script — see #299's lesson about markers). Per-file base64 is deterministic by construction; there's a regression test for it. Asset contents are folded into the marker, so editing a config re-converges and restarts the units consuming it — which is the behaviour you want and the reason this belongs in the provisioner rather than in a side-channel script. Everything ships inside ONE `pct exec` command line, so a large tree would blow past the shell's argument limit with a baffling error. Capped at 1 MiB with an explicit message pointing at the real fix (fetch large artifacts on the host). The Monitoring tree is 9 files / 108 KB, comfortably inside it. Side benefit: this is the only workable route to a healthcheck whose command needs quoting (gotcha #10) — render a script and point HealthCmd at it quote-free. 132 engine tests pass (9 new). Refs #303, #284
Closed
6 tasks
ChrisonSimtian
added a commit
that referenced
this pull request
Jul 27, 2026
…nitoring stack Two engine defects that only a real, large, multi-image stack exposes. Both found on CT 4001 (#303). 1. ASSETS BLEW PAST THE COMMAND-LENGTH LIMIT. #305 embedded the whole asset tree in the single `pct exec` deploy script. The monitoring tree is 286 KiB of base64 (a 100 KB generated snmp.yml + a 97 KB Grafana dashboard) and the SSH connection was reset outright — "Connection reset by peer", with NOTHING executed, not even the first useradd. Not a timeout, so yesterday's keepalives were irrelevant. Measured on this path: 96 KiB of command line works, 128 KiB does not. So my 1 MiB cap in #305 was ~10x too generous, and the guard I wrote specifically to prevent a baffling failure produced one. Fixed architecturally rather than with a smaller number: assets now go out as separate 32 KiB chunks BEFORE the deploy script (first chunk truncates, rest append, decode once), so tree size stops mattering. The cap is demoted to a 16 MiB sanity bound. A test asserts no single command exceeds 64 KiB. 2. ROOTLESS CANNOT UNPACK DISTROLESS IMAGES without ignore_chown_errors. The exportarr image owns files as uid 65532 (/home/nonroot), which is outside the subuid window the LXC's own 65536-uid map allows: "potentially insufficient UIDs or GIDs available in user namespace (requested 65532:65532 for /home/nonroot)" Widening the range can't fix it — mapping container uid 65532 needs ~65533 subuids inside a 65536-wide window, leaving nothing for real accounts. The provisioner now writes ~/.config/containers/storage.conf with ignore_chown_errors=true, before anything pulls an image. Note that only fixes the PULL. RUNNING such an image as its own high uid additionally needs `UserNS=keep-id:uid=<uid>` on the quadlet, or crun refuses: "setgroups: Invalid argument". Verified both halves by hand before encoding. 134 engine tests pass (2 new; 3 obsolete ones replaced — they asserted assets appear inside the deploy script, which is now wrong by design). Refs #303, #305
ChrisonSimtian
added a commit
that referenced
this pull request
Jul 27, 2026
…nitoring stack Two engine defects that only a real, large, multi-image stack exposes. Both found on CT 4001 (#303). 1. ASSETS BLEW PAST THE COMMAND-LENGTH LIMIT. #305 embedded the whole asset tree in the single `pct exec` deploy script. The monitoring tree is 286 KiB of base64 (a 100 KB generated snmp.yml + a 97 KB Grafana dashboard) and the SSH connection was reset outright — "Connection reset by peer", with NOTHING executed, not even the first useradd. Not a timeout, so yesterday's keepalives were irrelevant. Measured on this path: 96 KiB of command line works, 128 KiB does not. So my 1 MiB cap in #305 was ~10x too generous, and the guard I wrote specifically to prevent a baffling failure produced one. Fixed architecturally rather than with a smaller number: assets now go out as separate 32 KiB chunks BEFORE the deploy script (first chunk truncates, rest append, decode once), so tree size stops mattering. The cap is demoted to a 16 MiB sanity bound. A test asserts no single command exceeds 64 KiB. 2. ROOTLESS CANNOT UNPACK DISTROLESS IMAGES without ignore_chown_errors. The exportarr image owns files as uid 65532 (/home/nonroot), which is outside the subuid window the LXC's own 65536-uid map allows: "potentially insufficient UIDs or GIDs available in user namespace (requested 65532:65532 for /home/nonroot)" Widening the range can't fix it — mapping container uid 65532 needs ~65533 subuids inside a 65536-wide window, leaving nothing for real accounts. The provisioner now writes ~/.config/containers/storage.conf with ignore_chown_errors=true, before anything pulls an image. Note that only fixes the PULL. RUNNING such an image as its own high uid additionally needs `UserNS=keep-id:uid=<uid>` on the quadlet, or crun refuses: "setgroups: Invalid argument". Verified both halves by hand before encoding. 134 engine tests pass (2 new; 3 obsolete ones replaced — they asserted assets appear inside the deploy script, which is now wrong by design). Refs #303, #305
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.
Prerequisite for #303, split out so it's reviewed and gated on its own.
Why
Quadlets cannot carry a stack's configuration, and the Monitoring stack is mostly configuration: prometheus/snmp/loki/tempo/otel YAML plus Grafana provisioning and dashboards.
Today
stacks/monitoring/deploy/install.shtars the tree into the CT and runsdocker compose up. Keeping that while quadlets come from converge would mean two deploy paths, two sources of truth, and an ordering hazard — a unit can start before the config it mounts exists.What
Rendered recursively (parents created),
.sh→0755and everything else0644, then chowned to the rootless user. Emitted before units start, so a unit never mounts a config that isn't there — there's a test asserting the ordering.Two design decisions worth reviewing
Per-file base64, not a tarball. A tar embeds mtimes, so the emitted script would differ on every run and churn the managed marker (which hashes the script — the lesson from #299/#294). Per-file rendering is deterministic by construction, and there's a regression test pinning that.
Asset contents are folded into the marker, so editing a config re-converges and restarts the units consuming it. That's the behaviour you want, and it's the reason this belongs in the provisioner rather than a side-channel script.
Guard rail
Everything ships in one
pct execcommand line, so a big tree would overflow the shell's argument limit with a baffling error. Capped at 1 MiB with an explicit message pointing at the real fix. Monitoring's tree is 9 files / 108 KB — comfortably inside.Side benefit
This is the only workable route to a healthcheck whose command needs quoting (gotcha #10): render a script, point
HealthCmdat it quote-free.132 engine tests pass (9 new) — covering recursive discovery, ordering vs unit start, exec bits, marker determinism with assets present, marker change on asset edit, and the size cap.
🤖 Generated with Claude Code