Repository navigation
feat(sandbox): vendor the GitHub CLI (gh) into the sandbox images - #661
Conversation
docs/sbx/user-guide.md promises gh works in a sandbox (gh pr create under the sbx credentials feature), but no image carried the binary: gh is not in the UBI 9 repositories, so sandboxes shipped without it and every gh call failed with exit 127 in an otherwise healthy sandbox. Vendor gh the way rg is vendored: upstream release tarball pinned by version (2.103.3) and per-arch sha256, sha256sum -c fails the build closed, fetched in its own stage so the unpack tools stay out of the runtime image. The upstream binary links glibc only, which ubi-minimal carries; gh --version at the end of the RUN fails the build if that ever stops being true (live-verified in a RHEL 9.8 rootfs chroot). - both remote-worker Dockerfiles gain the stage and the COPY - probed gains gh, so Hello.capabilities advertises it; dockerfile_parity_test.go maps it and pins the gh pinning itself - build-snapshot.sh's guest probe and build-rootfs.sh's REQUIRED_TOOLS gain gh (both are pinned against the Go probed list by their tests, which is what made this change test-first) Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Vendors gh 2.103.3 into both remote-worker images, the same way rg is vendored (pinned version, per-arch sha256, sha256sum -c fails closed, separate fetch stage). It also adds gh to probed, the microVM guest probe, and REQUIRED_TOOLS, and pins the vendoring with a new parity test.
I verified that both pinned digests match the upstream gh_2.103.3_checksums.txt (amd64 4c80…d91d, arm64 ee32…ce63). v2.103.3 is a non-prerelease release, the current latest. Every hard-coded probed list I could find (build-rootfs.sh REQUIRED_TOOLS, build-snapshot.sh guest probe) is updated, and both are already pinned against the Go list by their tests. All 17 checks are green, including hadolint, deploy-scripts and deploy-scripts-bash32.
One nit on the Dockerfile comment: the linux gh binary is statically linked, not glibc-dynamic.
Assisted-By: Claude Code
| # repositories, and adding GitHub's own dnf repo would put a third-party repository into an image | ||
| # that executes model-authored commands. Upstream release tarball, pinned by version and checked | ||
| # against the sha256 the release publishes (gh_<version>_checksums.txt). The upstream binary is | ||
| # dynamically linked against glibc only, which ubi-minimal carries; the `gh --version` at the end |
There was a problem hiding this comment.
nit: The comment says the upstream binary is "dynamically linked against glibc only". It isn't. I downloaded gh_2.103.3_linux_amd64.tar.gz (sha256 matches the pin) and file reports it as "ELF 64-bit LSB executable, x86-64, … statically linked, Go BuildID=…". gh's linux release builds are CGO-free static Go binaries. This doesn't change behaviour; if anything it's safer, because there's no libc coupling. But the comment gives the wrong reason for the gh --version guard. Suggest: "The upstream binary is a static Go build, so it needs nothing from ubi-minimal; gh --version at the end of the RUN still fails the build closed if a release ever ships a broken or wrong-arch binary." The same wording is in the other Dockerfile.
There was a problem hiding this comment.
Verified against the pinned tarball: file reports statically linked, Go BuildID. Comment corrected in 840825f — the gh --version guard stays, restated for what it actually covers (a release shipping a binary that does not run on the built arch).
| # repositories, and adding GitHub's own dnf repo would put a third-party repository into an image | ||
| # that executes model-authored commands. Upstream release tarball, pinned by version and checked | ||
| # against the sha256 the release publishes (gh_<version>_checksums.txt). The upstream binary is | ||
| # dynamically linked against glibc only, which ubi-minimal carries; the `gh --version` at the end |
There was a problem hiding this comment.
nit: The same "dynamically linked against glibc" wording is here; see the comment on remote-worker/Dockerfile:82. The release binary is statically linked.
The gh stage's comment claimed the upstream binary is dynamically linked against glibc only; it is a static, CGO-free Go build (file: "statically linked, Go BuildID"), so it needs nothing from ubi-minimal's libc. The gh --version guard stays, restated for the reason it actually covers: a release shipping a binary that does not run on the built arch. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Takes upstream's 11 commits after 071b213: gh vendored into the sandbox images (rossoctl#661), the sandbox image pulled on every run in both VM paths (rossoctl#665) and in compose (rossoctl#664), a cached login matched by endpoint (rossoctl#667), a kind-ci fix (rossoctl#663). No conflicts. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Why
docs/sbx/user-guide.md§6 promises thatghworks in a sandbox — `gh pr create` under the sbx credentials feature — but no image carried the binary.ghis not in the UBI 9 repositories, so every sandbox shipped without it and eachghcall failed with exit 127 inside an otherwise healthy, attached sandbox.What
remote-worker/Dockerfile/Dockerfile.runtime: aghbuild stage, vendored the wayrgis — upstream release tarball pinned by version (2.103.3) and per-arch sha256,sha256sum -cfails the build closed, fetched in its own stage so the unpack tools never reach the runtime image. The upstream binary links glibc only, which ubi-minimal carries;gh --versionat the end of the RUN fails the build if that ever changes (live-verified in a RHEL 9.8 rootfs chroot on the SBX0 KVM host).cmd/worker/main.go:ghjoinsprobed, soHello.capabilitiesadvertises it.dockerfile_parity_test.go: aprovidesentry forgh(vendored token, so a comment cannot satisfy it) andTestVendoredGhIsPinnedAndChecksummedmirroring the rg pinning test — gh runs against the user`s GitHub identity under the sbx credentials feature, so a tampered download is not acceptable.build-snapshot.sh/build-rootfs.sh: the guest capabilities probe andREQUIRED_TOOLSgaingh. Both are pinned against the Goprobedlist by their own tests, which drove this change test-first (addingghtoprobedfailed all three suites until each file caught up).Test evidence
go test ./cmd/worker/— ok (was red on the un-mappedghentry before the Dockerfiles changed)deploy/microvm/tests/build-rootfs.test.sh— PASS (REQUIRED_TOOLS includes 'gh'was red first)deploy/microvm/tests/build-snapshot.test.sh— PASS (guest probe includes 'gh'was red first)gh api userreturns the PAT owner through moca-egress credential injection)Assisted-By: Claude Code