Skip to content

Feat: scope plain HTTP to the listed registries (MK8S-451) - #77

Open
riadelhajjaji-scality wants to merge 6 commits into
mainfrom
improvement/MK8S-451-scope-plain-http
Open

riadelhajjaji-scality wants to merge 6 commits into
mainfrom
improvement/MK8S-451-scope-plain-http

Conversation

@riadelhajjaji-scality

@riadelhajjaji-scality riadelhajjaji-scality commented Nov 17, 2026 •

Copy link
Copy Markdown

Component

agent, docs

Problem

--plain-http marked every registry insecure: a registry serving HTTPS no longer failed on a bad certificate, and anyone on the path could answer the HTTP attempt. It also excluded --ca-file, so a site with one plain HTTP registry and one signed by a private CA had no working setting.

On top of that, go-containerregistry tries HTTP on its own for a private or loopback IP and a localhost name, whatever we configure. An on-premises registry usually has such an address.

Fix

  • Agent: --plain-http is replaced by --plain-http-registry=<host[:port]>, repeatable, matched exactly against the sources' registry. Entries are validated and normalized at startup (docker.io → index.docker.io) and logged with a warning. It works with --ca-file, not with --insecure-skip-tls-verify.
  • New transport (httpsOnly in puller.go): refuses a plain HTTP request to the pulled registry unless it is listed, so the library's own fallback can't reach it and a bad certificate fails the pull again. A redirect to another host, such as blob storage on plain HTTP, goes through: each blob is checked against its digest.
  • imagecachectl import: keeps --plain-http, now scoped to the registry of its one source, through the same transport.
  • Tests and docs: tests that relied on the fallback now list their registry. The matching rules live in agent/README.md; README.md and agent/DESIGN.md link to them.

⚠️ Breaking: the agent refuses --plain-http and won't start with it. Pass --plain-http-registry with the registry the ImageCache sources name instead. A plain HTTP registry on a private or loopback IP or a localhost name, which the library used to reach over HTTP unlisted, must now be listed too, and imagecachectl import needs --plain-http for it.

Test

Check Result
make -C agent test, make -C agent lint OK
Unit: unlisted plain HTTP registry on a private, loopback or localhost address is refused, no request reaches it OK, fails without the fix
Unit: unlisted HTTPS registry reached by IP still pulls (the HTTP race is refused, HTTPS wins) OK
Unit: HTTPS registry redirecting blobs to plain HTTP storage still pulls OK
Unit: a listed plain HTTP registry and an HTTPS one pulled by the same agent OK
Unit: entry validation and normalization, --ca-file accepted, --insecure-skip-tls-verify refused OK
e2e: source naming the plain registry by its ClusterIP stays pending unlisted, syncs once listed OK in CI
kind: listed HTTP, unlisted HTTP, HTTPS with private CA, HTTPS unknown CA synced, refused, synced, x509 error

Out of scope

  • Switching MetalK8s to --plain-http-registry.
  • Citadel design update.

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

Relates-to: #MK8S-451

@riadelhajjaji-scality riadelhajjaji-scality self-assigned this Nov 17, 2026
Comment thread agent/cmd/manager/main.go Resolved
@riadelhajjaji-scality
riadelhajjaji-scality force-pushed the improvement/MK8S-451-scope-plain-http branch from b7e390a to 8333d2e Compare November 17, 2026 14:15
@riadelhajjaji-scality
riadelhajjaji-scality marked this pull request as ready for review November 17, 2026 14:20
@riadelhajjaji-scality
riadelhajjaji-scality requested a review from a team as a code owner November 17, 2026 14:20
Comment thread agent/internal/puller/puller.go Resolved
Comment thread agent/internal/puller/puller_test.go Resolved
Comment thread agent/test/e2e/e2e_test.go Resolved
Comment thread agent/README.md Resolved
--plain-http marked every registry insecure, so go-containerregistry
raced HTTPS and HTTP for all of them: a registry serving HTTPS no longer
failed on a bad certificate, and anyone on the path could answer the
HTTP attempt. It also excluded --ca-file, leaving a site with one plain
HTTP registry and one signed by a private CA with no working setting.

Replace it on the agent with --plain-http-registry=<host[:port]>,
repeatable. Only a source whose registry matches an entry exactly is
marked insecure; every other registry stays HTTPS only. Entries are
validated and normalized at startup and logged with a warning. The list
goes with --ca-file and still excludes --insecure-skip-tls-verify.

Marking a registry is not the only way the library reaches for HTTP: it
also races HTTP on its own for a private or loopback IP address and for
a localhost name, whatever the list says, and nothing turns that off.
Every pull therefore goes through a transport that refuses a plain HTTP
request to an unlisted registry before it leaves, so only the HTTPS
attempt is left and a bad certificate fails the pull again. Without it,
a registry on a private address, the usual case on premises, would be
reached over plain HTTP listed or not.

imagecachectl import keeps its --plain-http switch, now scoped to the
registry of its single source, and goes through the same transport.

BREAKING CHANGE: the agent no longer accepts --plain-http and refuses to
start with it. Pass --plain-http-registry with the registry the
ImageCache sources name instead. A plain HTTP registry on a private or
loopback IP address or a localhost name, which the library used to reach
over HTTP unlisted, must now be listed too, and imagecachectl import
needs --plain-http for it.
A registry on HTTPS that redirects its blobs to storage on plain HTTP
failed the pull. Only the pulled registry is held to HTTPS now: a
redirect elsewhere is safe, each blob is checked against its digest.
The registries are named by their Service, so the library never tried
plain HTTP for them. A source with the ClusterIP, a private address,
stays pending unlisted and syncs once listed.
…MK8S-451)

They were written in four places. DESIGN.md links to them, the flag help
and the TLS godoc keep one line.

By("creating an ImageCache that names the registry by its ClusterIP, unlisted")
worker := utils.WorkerNode()
applyImageCacheFrom(plainIPName, worker, host+"/e2e/carrier:1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the other state a spec leaves behind (the registry-ca ConfigMap, the agent patch, the seeded directories) goes through DeferCleanup, but the ImageCache doesn't. If an assertion below fails, it stays, and so does its directory on the worker. I'd register its deletion right after this line, like the rest (go vet -tags e2e is fine with it):

DeferCleanup(func() {
	_, _ = utils.Run(exec.Command("kubectl", "delete", "imagecache", plainIPName, "--ignore-not-found"))
})

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.

2 participants