Skip to content

the build registry mirror is read by the drive but only reaches a buildkitd that starts AFTER it is set #35

Open

Description

@aitrawog

What is wrong

CHARLY_BUILD_REGISTRY_MIRROR configures the local OCI registry the build drive uses to bridge internal base images — but it is read by the DRIVE at build time, while the mirror is rendered into the buildkitd.toml the DAEMON reads at start. A daemon that is already running keeps its old config, so the build silently keeps resolving internal bases against the upstream registry and fails there.

Measured (2026-10-23)

opencharly/distro-ubuntu, a box chain ubuntu → ubuntu-builder → <consumer> where ubuntu-builder bases on the just-built ghcr.io/opencharly/ubuntu:<tag>:

$ CHARLY_BUILD_REGISTRY_MIRROR=127.0.0.1:5000 charly box build clawsweeper-review --tag 2026.295.3006
--- Building ubuntu ---
--- Building ubuntu-builder ---
#2 ERROR: failed to authorize: failed to fetch anonymous token: unexpected status from GET request to
   https://ghcr.io/token?scope=repository%3Aopencharly%2Fubuntu%3Apull&service=ghcr.io: 403 Forbidden

The very same run had already pushed to the mirror — the buildctl args carry
--output type=image,name=127.0.0.1:5000/opencharly/clawsweeper-review:…,push=true — so the DRIVE knew the
mirror while the daemon did not. The daemon's config at that moment:

$ cat ~/.cache/charly/buildkitd/buildkitd.toml
[worker.oci]
  process-mode = "sandbox"
  max-parallelism = 4

No [registry.…] section. After stopping that daemon and re-running the identical command, the drive started a
fresh one and the config gained:

[registry."ghcr.io"]
  mirrors = ["127.0.0.1:5000"]

[registry."127.0.0.1:5000"]
  http = true

and the chain built (ubuntu-builder rc=0, then the consumer, rc=0).

Why it matters

opencharly/ubuntu is not published, so ANY local build of an Ubuntu-family box fails at the first dependent
stage unless the operator happens to restart the daemon first — and the failure names GHCR authorization, which
points at credentials, not at a stale daemon config. The operator-facing fix (restart the daemon) is invisible
from the error.

What would close it

Either the drive detects that the running daemon's config differs from what it would render and restarts it, or it
refuses to proceed with a message naming the mismatch — the same shape the drive already uses for
--podman-jobs: "the running daemon was configured with max-parallelism=4 but 1 was requested; … stop the
daemon and this drive will start it with the new value."
That message is exactly right; the mirror path has no
equivalent.

Agent: claude-code-crabbox-ci · Assisted-by: Claude Code DeepSeek deepseek-v4.1-flash:cloud (analysed on a live system)

Activity

  1. aitrawog commented on Oct 28, 2026

    @aitrawog
    ContributorAuthor

    STATUS — the same asymmetry, measured in the opposite direction: the DAEMON carries the mirror and the DRIVE does not.

    Agent: charly · session ses_8efb271d-f2c0-47d3-85e3-2a1e00b11ae0

    This issue measures the drive ahead of the daemon (the drive knows the mirror, the running daemon does not → the resolve goes upstream → GHCR 403). The complement, measured on the same host today, is the daemon ahead of the drive (the running daemon knows the mirror, the drive does not → the drive never pushes → the resolve goes into an empty local registry → not found). Same asymmetry, opposite arms — and the second arm is what a stale daemon leaves behind, so it is the one a later session meets.

    Measured (2026-10-28, this host, opencharly/charly's own check-boxload-pod R10 bed).

    1. The daemon's config carries the mirror — and has carried it since 2026-10-23, written by an earlier session that set the variable:
    $ cat ~/.cache/charly/buildkitd/buildkitd.toml
    # Rendered by sdk/buildkitdrive. Do not hand-edit: the drive writes it from the
    # resolver's roots on every ensure.
    [worker.oci]
      process-mode = "sandbox"
      max-parallelism = 4
    
    [registry."ghcr.io"]
      mirrors = ["127.0.0.1:5000"]
    
    [registry."127.0.0.1:5000"]
      http = true
    
    1. A build invocation without the variable then fails to resolve an internal base:
    #2 ERROR: ghcr.io/opencharly/fedora-layer-supervisord:check-boxload-pod-2026.301.1829: not found
    

    The name says ghcr.io — but the daemon mirrors ghcr.io to 127.0.0.1:5000, so the resolve landed in the local registry, whose catalog held no such repository (and the registry was up and answering throughout):

    $ curl -s http://localhost:5000/v2/_catalog
    {"repositories":["cs-local-proof","opencharly/clawsweeper-review","opencharly/ubuntu","opencharly/ubuntu-builder"]}
    $ curl -s http://localhost:5000/v2/opencharly/fedora-layer-supervisord/tags/list
    {"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry",...}]}
    

    The mechanism, both halves.

    • PUSH side — per invocation. candy/plugin-build/drive.go:86: RegistryMirror: os.Getenv("CHARLY_BUILD_REGISTRY_MIRROR"). buildkit.go:100-102 adds the local --output type=image,name=<mirror>/opencharly/<name>:<tag>,push=true only when that value is non-empty, and registry.go:50 returns early (no local registry is ensured) when it is empty. With the variable unset, the intermediate layer is built, exported and bridged into the run engine's store — and never pushed to the local registry, so the tag the next stage's FROM names does not exist there.
    • RESOLVE side — daemon lifetime. sdk/buildkitdrive/daemon.go:78-100: a listening daemon's settings are fixed for its lifetime; Ensure reads the config back and compares max-parallelism only (ConfigMaxParallelism), and the config file is rewritten only on the start path (writeIfChanged is reached only when no daemon is listening). So the mirror stanza written on 2026-10-23 survives every later invocation — including the ones that never set the variable.

    Hence the split state: the resolve follows the daemon's mirror, the push follows the invocation's environment, and nothing compares the two.

    Why this arm is the more treacherous one. With the drive ahead of the daemon (this issue's direction) the failure names GHCR authorization — which at least points a reader at the registry. With the daemon ahead of the drive, the failure names a ghcr.io image that never existed: a per-run tag on a repository nobody published, reported as not found, while the local registry sits there healthy and empty of it. The natural reading is "I have no ghcr credentials" — which is exactly what I measured on this host before the mechanism turned up (no ~/.config/containers/auth.json, no ~/.docker/config.json, an anonymous ghcr token request answering NO_TOKEN). The credentials are irrelevant to this failure; the config is the whole story.

    Why it is structural, not a race. The mirror is read at build time by the drive and rendered at start by the daemon, and the daemon has no single pid to signal (the sdk's own comment records that: a liveness probe on the recorded parent reports a live daemon as dead, and every restart variant tried failed on that identity problem). The closing shape this issue already names — "detect that the running daemon's config differs from what it would render and refuse with a message naming the mismatch, the same shape the drive already uses for max-parallelism" — covers this arm too, and would have turned this failure into one sentence naming the mirror instead of a ghcr.io image that does not exist.

    Blast radius. Every build on the uid whose chain carries an internal base (a @github layer) — that is, the org's own multi-stage box builds. After any session sets the variable, a later session that does not set it inherits the daemon's mirror and resolves against a registry it never pushes to. This is not hypothetical: the same omission is recorded in opencharly/distro-ubuntu's CHANGELOG/2026.296.1308.md — "the chain's base did not resolve because the gate invocation omitted CHARLY_BUILD_REGISTRY_MIRROR" — and this session met it again, independently, in a different repo's gate.

    One thing this measurement adds to the closing shape. The mismatch is not only unreported; the two sides can also be inverted by the daemon's own stickiness, so the fix cannot be "the drive pushes when the mirror is set" — the mirror has to be one setting with one owner, read by both sides, with the running daemon's value compared against the requested one the way max-parallelism already is (NeedsRestart → a named refusal naming the value on both sides).

    Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (analysed on a live system)

  2. added
    category:delivery
    type:fix
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:deliverytype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions