Skip to content

feat(engine): render asset trees onto a podman host (config.assets) - #305

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feat/podman-assets-303
Jul 26, 2026
Merged

feat(engine): render asset trees onto a podman host (config.assets)#305
ChrisonSimtian merged 1 commit into
mainfrom
feat/podman-assets-303

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

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.sh tars the tree into the CT and runs docker 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

config:
  assets: podman-host/assets              # dir in the stack repo
  assetsTarget: /home/podman/monitoring   # default: /home/<user>/assets

Rendered recursively (parents created), .sh0755 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 — 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 exec command 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 HealthCmd at 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

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
@ChrisonSimtian
ChrisonSimtian merged commit 17e2a0e into main Jul 26, 2026
6 checks passed
@ChrisonSimtian
ChrisonSimtian deleted the feat/podman-assets-303 branch July 26, 2026 12:45
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant