refactor(orch): render the distro selection in provision.sh's own template - #3463
tomassrnka wants to merge 2 commits into
Conversation
PR SummaryMedium Risk Overview Base-layer cache versioning splits responsibility: the embedded Reviewed by Cursor Bugbot for commit 77d963e. Bugbot is set up for automated code reviews on this repo. Configure here. |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
9437ec6 to
4b6d895
Compare
4b6d895 to
3f449f6
Compare
The three initSetup bodies leave their Go string literals for
init-{systemd,openrc,nixos}.sh, go:embed'd with the trailing newline
trimmed so they splice exactly like the literals did. Selector output is
unchanged apart from the entry comments moving in as # lines.
Rebased over #3440, which added chrony-source wiring to both init blocks
after this was written: the systemd drop-in, OpenRC's e2b-chrony-source
install and the unconditional command_args="-F 0" move into the new
files verbatim, checked byte-for-byte against main's literals.
First half of the #3411 follow-up (dobrac: init.go:21).
…plate
The selection structure (case arms, rejected-id guard, ID_LIKE loop,
error/warning text) moves verbatim from the ShellSelector string-builder
into provision.sh as inline template actions; the distro package now
contributes data only — distro.NewTemplateData(), with all shell-quoting
kept in Go. Fingerprint hashes the view data (%#v, so new fields are
covered automatically); the structure is already hashed via the raw
embedded template. Version 1 -> 2.
The render seam and its tests live in ungated files so they keep running
on darwin. Selection-text assertions move to base/provision_test.go
against the rendered script, with the guard-ordering anchor rewritten to
the fallback loop line (E2B_ID_LIKE is assigned earlier in the full
script). New guards: %q-vs-sh quoting assumptions pinned per profile
field, a leftover-"{{" render check, and a test that every ProfileView
field — including the init-setup body now sourced from a file — reaches
the rendered case arm. A dropped template action would otherwise leave
the Go-side tests green while the guest hits an undefined variable under
set -u.
#3440's chrony-deferral test now asserts on the rendered script rather
than the raw template: the init blocks moved out, so only the rendered
form covers both halves.
Rendered output verified byte-identical to main's ShellSelector output
modulo the added comments; customer-visible messages pinned byte-exact.
Completes the #3411 follow-up (dobrac: distro.go:160, provision.sh:29).
3f449f6 to
5b134af
Compare
5b134af to
77d963e
Compare
|
Found 1 test failure on Blacksmith runners: Failure
|
![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light.png)
Follow-up promised in the #3411 review (@dobrac's three comments: Go templating for the selector, profiles-as-data with selection living in provision.sh, init blocks in separate files). #3459 has merged; this sits directly on main.
What changed: the distro-selection block (case arms, rejected-id guard, ID_LIKE loop, all error/warning text) moved verbatim from the
ShellSelector()string-builder into provision.sh as inlinetext/templateactions; thedistropackage now contributes data only (distro.NewTemplateData()), with shell-quoting kept unit-testable in Go and noFuncMap(repo precedent). Init-setup blocks moved todistro/init-{systemd,openrc,nixos}.sh,go:embed'd.Cache key: selection structure is covered by the raw embedded provision.sh that
Hash()already hashes;distro.Fingerprint()(%#vof the view) covers the spliced data, so new fields fingerprint automatically.Version1 → 2 — the dev/fallback provision version rotates once on deploy; production rollout stays gated by theBuildProvisionVersionLD flag.Verification: rendered output diffed against the old
ShellSelector()— byte-identical for the whole selection function, only deliberate comment/blank-line additions in the tail. Full e2e on an E2B Local dev slot (cold cache, orchestrator rebuilt from this branch):oraclelinux:9rejected with byte-identical ERROR lines;kalibuilds with the byte-identical ID_LIKE WARNING and boots;alpine(OpenRC path) builds and boots with envd healthy;ubuntuanddebianbuild and boot.sh -n,bash -n,shellcheck -s shclean on the three new files and the rendered script.Tests: selection-text assertions moved to
base/provision_test.goagainst the fully rendered script (render seam and tests are build-tag-free, so they run on darwin); every prior assertion preserved, incl. the errexit guard (noif e2b_select_profile) and guard-before-fallback ordering; new per-field%q-vs-sh quoting pins, byte-exact customer-message pins, and a leftover-{{render check. NewTestProvisionScriptSplicesEveryProfileFieldasserts everyProfileViewfield — including the init-setup body now sourced from a file — reaches its rendered case arm: a dropped template action would leave the Go-side tests green while every distro hits an undefined variable underset -eu. It subsumes the removedTestProvisionScriptInitSetup.Rebase onto current main (#3440, #3478): semantic, not textual — both touch the moved code. #3440's chrony wiring (the systemd
$E2B_TIMESYNC_UNIT.service.ddrop-in, OpenRC'se2b-chrony-sourceinstall, the unconditionalcommand_args="-F 0") now lives ininit-openrc.sh/init-systemd.sh, verified byte-for-byte against main's literals; its tests are kept, with the chrony-deferral test now reading the rendered script. #3478'sInitBinary: "/sbin/e2b-nixos-init"survives thedistro.gorewrite and renders asE2B_INIT_BIN="/sbin/e2b-nixos-init". Tree swept for orphans of the moved code (E2B_CHRONY_PHC,command_args="-F 0",e2b-chrony-source,E2B_TIMESYNC_UNIT,E2B_INIT_BIN,/sbin/e2b-nixos-init,ShellSelector,DistroSelector): every consumer has a definition, none stranded. Re-verified after the rebase: rendered script still byte-identical to main'sShellSelector()output apart from the comments.🤖 Generated with Claude Code