Skip to content

feat(agent): pull through a registry mirror, then the source registry (MK8S-553) - #81

Open
ezekiel-alexrod wants to merge 8 commits into
mainfrom
improvement/MK8S-553-registry-mirror
Open

ezekiel-alexrod wants to merge 8 commits into
mainfrom
improvement/MK8S-553-registry-mirror

Conversation

@ezekiel-alexrod

@ezekiel-alexrod ezekiel-alexrod commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Component

agent, docs

Problem

go-containerregistry has no mirror support. So today an ImageCache source must carry the registry address, like <ip>:5000/metalk8s-<ver>/.... containerd pulls ghcr.io/scality/... and lets its mirror config redirect it. We want the same real name in the ImageCache resources.

Fix

A --mirror=<host[:port]> flag on the agent and on imagecachectl import. A source ghcr.io/scality/x:1.0 is pulled from <mirror>/v2/scality/x/...?ns=ghcr.io first, like containerd does, then from ghcr.io if the mirror fails. When both fail, the error gives both causes.

Review guide: please read the commits in order, each one builds and passes its tests.

  1. The design, in agent/DESIGN.md ("Image pulling"). It says what the next commits do, and what the mirror is trusted for.
  2. A small refactor, no change in behaviour.
  3. The core: open, onMirror and withNamespace in agent/internal/puller/puller.go. This is where I'd like most of the feedback.
  4. A pull uses the mirror only if it has every layer (one HEAD per layer). The adoption check does not ask.
  5. A mirror passed over is logged, since the pull worked. agent/AGENTS.md notes this exception.
  6. to 8. The agent flag, the e2e spec on kind, and imagecachectl.

Design in citadel: scality/citadel#399, section "Registry mirror".

Test

Check Result
make -C agent test lint, go test -race OK
make -C agent test-e2e: mirror first, then the registry when the mirror misses a layer or is stopped 8/8
Each new unit test fails without the code it covers checked
Acceptance run on kind with a real static-oci-registry

The agent DaemonSet, with static-oci-registry (main) on the host as a TLS mirror, CA through the shipped registry-ca patch:

  • ghcr.io/... source, by tag and by digest: synced through the mirror, ns=ghcr.io on each request, the sentinel keeps the real source.
  • Layer removed from the mirror, ghcr.io refused: pending with both causes, then synced once the layer is back.
  • Mirror stopped: synced from the registry, and the agent logs the mirror it passed over.
  • imagecachectl on the worker node, mirror given as an IP, then adopted by the agent: the adoption asked the mirror for one manifest and the config, no layer.

Out of scope

  • One mirror per registry.
  • Switching the MetalK8s Salt states to the real source and passing --mirror (follow-up in metalk8s).
  • A mirror that drops packets costs a dial timeout on each resolve.

Known limits

  • static-oci-registry refuses an ns with a port (NAME_INVALID), so a source registry with a port cannot use it as a mirror. Sources like ghcr.io/... are fine.
  • A pull-through proxy that fetches a blob only on a GET would answer the HEAD with 404 and be passed over.

  • Docs updated: README.md, agent/README.md, agent/DESIGN.md, agent/AGENTS.md.
  • Cache layout change. Not applicable.

Relates-to: MK8S-553

@ezekiel-alexrod
ezekiel-alexrod force-pushed the improvement/MK8S-553-registry-mirror branch from 3534b53 to 2a7c6b1 Compare November 23, 2026 14:02
@riadelhajjaji-scality
riadelhajjaji-scality force-pushed the improvement/MK8S-451-scope-plain-http branch from f108e11 to 5bb8cd5 Compare November 24, 2026 13:26
Base automatically changed from improvement/MK8S-451-scope-plain-http to main November 26, 2026 12:45
@ezekiel-alexrod
ezekiel-alexrod force-pushed the improvement/MK8S-553-registry-mirror branch from 2a7c6b1 to c8de007 Compare November 26, 2026 13:35
Comment thread agent/DESIGN.md Resolved
Comment thread agent/internal/puller/puller.go Resolved
Comment thread agent/internal/puller/puller.go Resolved
Comment thread agent/internal/puller/puller.go Resolved
Comment thread agent/internal/cli/cli.go Resolved
Comment thread agent/internal/puller/puller.go Resolved
The image cache could only pull a reference that names the registry
address. This describes one global mirror, tried before the registry
the source names, as containerd does, so the ImageCache sources keep
the real image name. The next commits implement it.

Refs: MK8S-553
Both ways to build a Remote checked the plain HTTP list on their own.
The mirror adds a second registry to check, so the two now share
withRegistries. No change in behaviour.

Refs: MK8S-553
With a mirror, a source keeps its real name, like ghcr.io/scality/x:1.0,
and is pulled from <mirror>/scality/x:1.0 first, with ns=ghcr.io on the
registry API requests, as containerd does. When the mirror fails, the
registry the source names is tried, and when both fail the error
carries both causes.

The mirror reference is built from the mirror registry, so a short
host name stays the registry, and the mirror goes through the same
TLS and plain HTTP settings as any registry.

Refs: MK8S-553
The layers stream after the mirror is picked. A mirror that served the
manifest but missed a layer then failed the pull on every pass, and the
registry was never tried. A pull now sends a HEAD for each layer before
it picks the mirror. The adoption check reads no layer, so it does not.

Refs: MK8S-553
When the registry serves the image after the mirror failed, nothing
failed, so there is no error to return. Without a log, a mirror that
always fails goes unnoticed until the node loses the registry too. It
is logged through the logr logger of the context, and agent/AGENTS.md
notes this one exception to "packages return errors".

Refs: MK8S-553
The agent takes the mirror as a flag and logs it at startup. Its
README says what the flag does and points to the design for the rest.

Refs: MK8S-553
A spec pulls a source the registry does not hold through the mirror,
then falls back on the registry when the mirror loses a layer and when
it is stopped, and checks the agent logs the mirror it passed over.
registryHost names the test registries in one place, and deployRegistry
enables deletes so a spec can remove a blob without a restart.

Refs: MK8S-553
imagecachectl import takes the same mirror. Its --plain-http then goes
to the mirror, and pairs with --ca-file, which covers the registry the
source names. The command warns about a mirror it passed over, and
names the mirror in its plain HTTP warning.

Refs: MK8S-553
@ezekiel-alexrod
ezekiel-alexrod force-pushed the improvement/MK8S-553-registry-mirror branch from 44e25d7 to 1482aab Compare November 27, 2026 09:25
@ezekiel-alexrod
ezekiel-alexrod marked this pull request as ready for review November 27, 2026 09:26
@ezekiel-alexrod
ezekiel-alexrod requested a review from a team as a code owner November 27, 2026 09:26
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