Skip to content

feat(agent): add --plain-http for a registry without TLS (MK8S-445) - #31

Merged
ezekiel-alexrod merged 1 commit into
mainfrom
feature/MK8S-445-plain-http
Oct 13, 2026
Merged

ezekiel-alexrod merged 1 commit into
mainfrom
feature/MK8S-445-plain-http

Conversation

@ezekiel-alexrod

Copy link
Copy Markdown
Collaborator

Component

agent, docs

Problem

The MetalK8s registry serves plain HTTP. go-containerregistry only falls back to HTTP for a loopback or private address, so a registry reached by host name or public IP can't be pulled from. That breaks the join on a node (MK8S-394) and the resources created at bootstrap (MK8S-396).

Fix

Stacked on #26, so the diff here is the last commit only. I'd mostly like eyes on the scheme note in agent/DESIGN.md ("Pulling and extraction") and on open in agent/internal/puller/puller.go.

  • The manager and imagecachectl import take --plain-http. It marks the registry insecure (name.Insecure), which is the library's own switch for this.
  • The library still tries HTTPS first. It also tries HTTP when HTTPS fails or takes more than 300ms, and the first answer wins. So with the flag, a certificate error on an HTTPS registry no longer fails the pull. agent/DESIGN.md says it.
  • Off by default, no manifest sets it. The agent logs a warning at startup, the command prints one before it pulls (not for an archive).
  • It excludes --ca-file and --insecure-skip-tls-verify: it's for a registry without TLS, so a certificate setting next to it is a mistake.

Test

Check Result
go test -race ./... with envtest, go vet, golangci-lint after cache clean (Go 1.26.0) OK
HTTP registry reached by host name: refused without the flag (HTTP response to HTTPS client), pulled with it, in puller and through imagecachectl import OK
HTTPS registry pulled with the flag set OK
Flag combined with --ca-file or --insecure-skip-tls-verify refused: imagecachectl names both flags, the manager exits on ErrTLS
make -C agent test-e2e on kind OK, but it doesn't set the flag
RPM tests not run, the RPM isn't touched

Out of scope

  • A per-registry list instead of a global flag. MetalK8s pulls from its own registry only, so one flag is enough today. A site mixing an HTTP registry and one signed by a private CA can't be served until then.
  • Setting the flag from MetalK8s: MK8S-394 and MK8S-396.

  • The docs describing this behaviour are updated in the same pull request: README.md, agent/README.md, DESIGN.md, agent/DESIGN.md, CONTRIBUTING.md, whichever owns it.
  • A change to the cache directory layout (subdirectory scheme, archive names, sentinel, permissions) lands in both halves and in agent/DESIGN.md. Not applicable.

Relates-to: MK8S-445

@ezekiel-alexrod
ezekiel-alexrod requested a review from a team as a code owner October 9, 2026 11:40
@ezekiel-alexrod
ezekiel-alexrod force-pushed the feature/MK8S-445-plain-http branch from 36cd54b to f7d31c7 Compare October 9, 2026 16:23
Comment thread agent/DESIGN.md Outdated
A registry that serves plain HTTP under a host name could not be
reached: go-containerregistry only falls back to HTTP for a loopback
or private address. The manager and imagecachectl import now take
--plain-http, which marks every registry insecure. The client still
tries HTTPS first, and tries HTTP too when HTTPS fails or is slow.

It is off by default and no manifest sets it. The agent logs a warning
at startup and the command prints one before it pulls. It excludes
--ca-file and --insecure-skip-tls-verify: it is for a registry without
TLS, so a certificate setting next to it is a mistake.

Relates-to: MK8S-445
@ezekiel-alexrod
ezekiel-alexrod force-pushed the feature/MK8S-445-plain-http branch from f7d31c7 to 7a23f8f Compare October 12, 2026 09:36
@ezekiel-alexrod
ezekiel-alexrod requested review from TeddyAndrieux, anthony-treuillier-scality and eg-ayoub and removed request for a team October 12, 2026 09:36
Base automatically changed from feature/MK8S-434-sentinel-owner to main October 12, 2026 09:38
@ezekiel-alexrod ezekiel-alexrod self-assigned this Oct 12, 2026
@ezekiel-alexrod ezekiel-alexrod added the P1 High priority label Oct 12, 2026
if r.plainHTTP {
// The library then races HTTPS and HTTP, see "Pulling and
// extraction" in agent/DESIGN.md.
nameOpts = append(nameOpts, name.Insecure)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

name.Insecure is applied to every reference, so the flag lets plain HTTP reach every registry. Once ping.go races the two schemes (pingParallel, 300ms fallbackDelay in go-containerregistry v0.21.7), anyone on the path can answer the HTTP attempt for a registry that serves HTTPS. agent/DESIGN.md documents this instead of fixing it. A small fix: take the host instead of a bool (--plain-http=<registry>, or a list), and add name.Insecure only when the reference's registry matches it. MetalK8s only needs its own registry, so the global form buys nothing. If you keep the global flag on purpose, the deferral belongs in the commit message: today it is only in the PR body.

@ezekiel-alexrod
ezekiel-alexrod merged commit 8398955 into main Oct 13, 2026
6 of 7 checks passed
@ezekiel-alexrod
ezekiel-alexrod deleted the feature/MK8S-445-plain-http branch October 13, 2026 06:55
ezekiel-alexrod added a commit to scality/metalk8s that referenced this pull request Oct 13, 2026
…S-166)

The MetalK8s registry serves plain HTTP. Without a flag, the agent only
falls back to it for a private IP literal, so a control plane on a
public range or named by a hostname could not fill its cache.

Move the agent to the build of scality/image-cache#31, which adds
--plain-http, and pass the flag to the DaemonSet.

Refs: MK8S-166
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants