ci: cut the Lint and Build fast-path network by environment #408

Merged
Defame1297 merged 4 commits from ci/168-offline-fast-path into main 2026-11-27 07:38:18 +00:00
Owner

What and why

Closes #168

On the fast path (the pin files match /opt/ci-pins.sha256), Lint and Build write a network guard into $GITHUB_ENV: PIP_NO_INDEX=1, http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY set to a dead local port (127.0.0.1:9), and no_proxy and NO_PROXY empty. Every later step inherits it, so a tool that downloads at run time fails the job instead of slowing it down silently. The bake-in rule (images/AGENTS.md) becomes a control. The slow path sets nothing and keeps network access.

  • Why not unshare: this is approach 2 of the issue comment. I tried approach 1 (unshare -rn) first, and the runner's job container refused it: unshare: unshare failed: Operation not permitted (Lint run 5880, Build run 5879, on commit 7c148e8). Commit 4d5042a replaces it.
  • What it catches: pip, curl, git over HTTPS, and Python's urllib or requests, meaning any client that honours PIP_NO_INDEX or the proxy variables.
  • What it does not catch: a raw socket, or a tool that ignores the proxy variables. Those stay held by review, as the rule in .gitea/workflows/AGENTS.md says.
  • "Test the repository scripts" unsets the guard. next_image_version.py uses urllib's default opener, so with no_proxy empty the tests' fake registry on 127.0.0.1 would be sent to the dead proxy. #187 moves these tests into a pre-commit hook, which runs under the guard, so that hook will need the same exception.
  • No changelog fragment: this is CI only.

Verified

  • CI on this PR, fast path: all green; the Lint log shows the guard notice after "The pin files match the ci image".
  • Acceptance 1, a runtime download fails the job. Lint 5888 was dispatched on a throwaway branch that added a fast-path step running pip download pyyaml. That step failed with No matching distribution found for pyyaml, and the job failed.
  • Acceptance 2, the slow path still installs and passes. Lint 5889 was dispatched on a throwaway branch that only added a comment to .pre-commit-config.yaml. It printed the pin-mismatch warning, set no guard, ran the pip and galaxy installs, and passed.
  • I deleted both throwaway branches afterwards, so their commits are not in this PR.
  • Locally, with the guard exported:
    • pre-commit run --all-files passed.
    • ansible-galaxy collection build passed.
    • check_tarball.py reported "344 entries, all allowed".
    • check_image_versions.py pins reported ok.
    • pip download, urllib and curl each failed with connection refused or no index.
  • Locally, script tests: 272 tests pass with the guard unset. With it exported, 6 fail with Connection refused, which is why that step unsets it.
  • Review: two reviews in separate subagents, one against the standards and one against the spec. Their finding was that the docs overclaimed the control; fixed and then reworded for the guard.

Not verified

  • I did not test git over HTTPS under the guard directly.
  • Slow-path run 5889 rebuilt no pre-commit hook environment, because a comment-only change leaves every hook's repo and rev unchanged. A slow path that does rebuild hooks was not exercised. It sets no guard, so it should behave as it does on main.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code

## What and why Closes #168 On the fast path (the pin files match `/opt/ci-pins.sha256`), Lint and Build write a network guard into `$GITHUB_ENV`: `PIP_NO_INDEX=1`, `http_proxy`, `https_proxy`, `HTTP_PROXY` and `HTTPS_PROXY` set to a dead local port (`127.0.0.1:9`), and `no_proxy` and `NO_PROXY` empty. Every later step inherits it, so a tool that downloads at run time fails the job instead of slowing it down silently. The bake-in rule (`images/AGENTS.md`) becomes a control. The slow path sets nothing and keeps network access. - **Why not `unshare`:** this is approach 2 of the issue comment. I tried approach 1 (`unshare -rn`) first, and the runner's job container refused it: `unshare: unshare failed: Operation not permitted` (Lint run 5880, Build run 5879, on commit 7c148e8). Commit 4d5042a replaces it. - **What it catches:** pip, curl, git over HTTPS, and Python's urllib or requests, meaning any client that honours `PIP_NO_INDEX` or the proxy variables. - **What it does not catch:** a raw socket, or a tool that ignores the proxy variables. Those stay held by review, as the rule in `.gitea/workflows/AGENTS.md` says. - **"Test the repository scripts" unsets the guard.** `next_image_version.py` uses urllib's default opener, so with `no_proxy` empty the tests' fake registry on 127.0.0.1 would be sent to the dead proxy. #187 moves these tests into a pre-commit hook, which runs under the guard, so that hook will need the same exception. - **No changelog fragment:** this is CI only. ## Verified - **CI on this PR, fast path:** all green; the Lint log shows the guard notice after "The pin files match the ci image". - [Lint 5886](https://git.rkdr.net/Mortis/Kamino/actions/runs/5886) - [Build 5885](https://git.rkdr.net/Mortis/Kamino/actions/runs/5885) - [Molecule 5887](https://git.rkdr.net/Mortis/Kamino/actions/runs/5887) - **Acceptance 1, a runtime download fails the job.** [Lint 5888](https://git.rkdr.net/Mortis/Kamino/actions/runs/5888) was dispatched on a throwaway branch that added a fast-path step running `pip download pyyaml`. That step failed with `No matching distribution found for pyyaml`, and the job failed. - **Acceptance 2, the slow path still installs and passes.** [Lint 5889](https://git.rkdr.net/Mortis/Kamino/actions/runs/5889) was dispatched on a throwaway branch that only added a comment to `.pre-commit-config.yaml`. It printed the pin-mismatch warning, set no guard, ran the pip and galaxy installs, and passed. - I deleted both throwaway branches afterwards, so their commits are not in this PR. - **Locally, with the guard exported:** - `pre-commit run --all-files` passed. - `ansible-galaxy collection build` passed. - `check_tarball.py` reported "344 entries, all allowed". - `check_image_versions.py pins` reported ok. - `pip download`, `urllib` and `curl` each failed with connection refused or no index. - **Locally, script tests:** 272 tests pass with the guard unset. With it exported, 6 fail with `Connection refused`, which is why that step unsets it. - **Review:** two reviews in separate subagents, one against the standards and one against the spec. Their finding was that the docs overclaimed the control; fixed and then reworded for the guard. ## Not verified - I did not test git over HTTPS under the guard directly. - Slow-path run 5889 rebuilt no pre-commit hook environment, because a comment-only change leaves every hook's repo and rev unchanged. A slow path that does rebuild hooks was not exercised. It sets no guard, so it should behave as it does on `main`. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code
Claude added this to the Continuous delivery milestone 2026-11-26 22:21:45 +00:00
Defame1297 was assigned by Claude 2026-11-26 22:21:45 +00:00
Claude added 2 commits 2026-11-26 22:21:46 +00:00
When the pins match the ci image every tool is baked in, so a runtime
download is a bake-in defect; failing the job makes it visible.

Assisted-by: Claude Code
docs: say what the network-off fast path does not hold
Build / build (pull_request) Failing after 8s
Lint / lint (pull_request) Failing after 12s
Molecule / molecule (pull_request) Successful in 13s
7c148e858d
A step without the $OFFLINE prefix runs online unchecked, and the script
tests keep network; both stay held by review.

Assisted-by: Claude Code
CODEOWNERS rules requested review from Defame1297 2026-11-26 22:21:46 +00:00
Defame1297 added 1 commit 2026-11-26 22:52:14 +00:00
ci: cut the fast-path network by environment, not unshare
Build / build (pull_request) Successful in 34s
Molecule / molecule (pull_request) Successful in 16s
Lint / lint (pull_request) Successful in 1m38s
4d5042a31f
The runner's job container refuses unshare, even with a user namespace, so the
fast path sets PIP_NO_INDEX and a dead proxy instead; a raw socket is not caught.

Assisted-by: Claude Code
Claude changed title from ci: run the Lint and Build fast path without network to ci: cut the Lint and Build fast-path network by environment 2026-11-26 22:59:10 +00:00
Defame1297 added 1 commit 2026-11-27 07:36:41 +00:00
Merge branch 'main' into ci/168-offline-fast-path
Build / build (pull_request) Successful in 28s
Molecule / molecule (pull_request) Successful in 4s
Lint / lint (pull_request) Successful in 1m31s
fbc8b1b6d7
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-27 07:36:46 +00:00
Defame1297 approved these changes 2026-11-27 07:36:51 +00:00
Defame1297 merged commit 3bf9ae0efe into main 2026-11-27 07:38:18 +00:00
Defame1297 deleted branch ci/168-offline-fast-path 2026-11-27 07:38:18 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#408