Skip to content

remotes/docker: Propagate registry warnings to the resolver - #12698

Merged
mxpv merged 1 commit into
containerd:mainfrom
vvoland:pull-headers
Aug 5, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
vvoland:pull-headers

Conversation

@vvoland

@vvoland vvoland commented Dec 17, 2025 •

Copy link
Copy Markdown
Contributor

According to the OCI distribution spec registries may include informational warnings in HTTP Warning headers:

This change implements support for handling these warnings and propagating them to the resolver.

This patch adds a new WarningHandler to ResolverOptions that allows callers to receive and process warnings sent by registries via HTTP Warning headers with warn-code 299.

Support propagating HTTP 299 warning headers from registries to the resolver

@vvoland
vvoland force-pushed the pull-headers branch 2 times, most recently from 4bda06d to e4e7969 Compare December 18, 2025 21:19
@vvoland
vvoland force-pushed the pull-headers branch 4 times, most recently from 00b1f46 to 80a1070 Compare January 7, 2026 12:37
@samuelkarp samuelkarp moved this from Needs Triage to Needs Reviewers in Pull Request Review Jan 7, 2026

@kzys kzys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry my memory around Resolver is a bit hazy... Are you using the callback for logging? Is it easy to tie the warning back to the ref and/or registry? I want to make sure that the warnings from the callback are actionable.

Comment thread core/remotes/docker/resolver.go Resolved
@vvoland
vvoland force-pushed the pull-headers branch 4 times, most recently from 2ec0ca6 to 4ff66fd Compare January 9, 2026 16:39
@vvoland

vvoland commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

My initial need was just gathering all the warnings for the whole operation rather than individual requests. This is quite trivial to obtain back from the resolver if you have one per each pull (we do that in docker pull).

However, I can see why that would be useful for the general usage so I added it.

Comment on lines +30 to +42
// WarningSource contains the information about the request that caused the warning.
type WarningSource struct {
// URL is the URL of the request that caused the warning.
URL string

// Desc is the descriptor of the content that the warning is for.
// Can be nil if the warning is not for a specific content.
Desc *ocispec.Descriptor

// Digest is the digest of the content that the warning is for.
// Can be nil if the warning is not for a specific content.
Digest *digest.Digest
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was thinking about just having Desc... But then it's awkward to use with FetchByDigest because we don't have a whole descriptor and passing a descriptor with only Digest set isn't great either.

Comment on lines +34 to +35
// Ref is the reference specification of the content that the warning is for.
Ref reference.Spec

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was URL initially, but thought that reference.Spec object might make more sense here?

@vvoland
vvoland force-pushed the pull-headers branch 3 times, most recently from ac5e931 to 358f730 Compare January 12, 2026 16:30
@vvoland
vvoland requested a review from kzys January 14, 2026 10:40
@samuelkarp

Copy link
Copy Markdown
Member

@vvoland Can you rebase?

// WarningHandler is called for each warning received from the registry.
// Warnings are reported via HTTP Warning headers with warn-code 299.
// If nil, warnings are ignored.
WarningHandler WarningHandler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not actually seeing this WarningHandler option set anywhere outside of test code; is it set somewhere else that I'm missing? Or is your use-case only in moby or buildkit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's for the downstream usage in moby.

Comment thread core/remotes/docker/warnings.go Resolved
Comment thread core/remotes/docker/warnings.go Resolved
}

func TestParseWarningText(t *testing.T) {
tests := []struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Go strings are byte slices, but processed as rune slices including multi-byte unicode runes. We should have test cases covering this. If warnings are only allowed to be ASCII, then there should be some detection and rejection of this during parseWarningText.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the obs-text handling. I didn't handle it as individual runes because RFC7230 seems to explicitly treat the message as sequence of octets rather than Unicode:

A recipient MUST parse an HTTP message as a sequence of octets in an encoding that is a superset of US-ASCII [USASCII].

// The warning parameter contains the warn-text from the header.
// The descriptor parameter contains the descriptor of the content that the warning is for.
// The descriptor is nil if the warning is not for a specific content.
type WarningHandler interface {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there an example WarningHandler implementation somewhere outside of test code? I think for containerd it might make sense to have a log handler at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if that's what you meant specifically but added a log handler here:

// LogWarningHandler is a WarningHandler that logs warnings using the
// containerd log package.
type LogWarningHandler struct{}
// Warn logs the warning message with source information.
func (LogWarningHandler) Warn(ctx context.Context, src WarningSource, warning string) {
fields := log.Fields{}
if ref := src.Ref.String(); ref != "" {
fields["ref"] = ref
}
if src.Digest != nil {
fields["digest"] = src.Digest.String()
}
log.G(ctx).WithFields(fields).Warn("registry warning: " + warning)
}

I didn't wire it up by default to the resolver though.

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/remotes/docker/fetcher.go Resolved
Comment thread core/remotes/docker/warnings.go Resolved
Comment thread core/remotes/docker/warnings_test.go Resolved
Comment thread core/remotes/docker/fetcher.go Resolved
Comment thread core/remotes/docker/pusher.go Resolved

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +414 to +416
// Save response headers for warning reporting later
if r.warningHandler != nil {
respHeaders = resp.Header.Clone()

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

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

In Resolve, respHeaders is cloned from the initial HEAD response, but if a subsequent GET is performed the code overwrites respHeaders with the GET headers. This drops any warnings that were only present on the HEAD response, so not all registry warnings encountered during resolution will be propagated. Consider accumulating warning header values across both responses (or storing parsed warnings) and reporting them all after the descriptor/digest are known.

Suggested change
// Save response headers for warning reporting later
if r.warningHandler != nil {
respHeaders = resp.Header.Clone()
// Save response headers for warning reporting later.
// If headers were already captured from the initial HEAD request,
// preserve any Warning values so all registry warnings encountered
// during resolution can be reported.
if r.warningHandler != nil {
getHeaders := resp.Header.Clone()
if respHeaders != nil {
for _, warning := range respHeaders.Values("Warning") {
getHeaders.Add("Warning", warning)
}
}
respHeaders = getHeaders

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah, that branch is really a fallback for edge case (both Docker-Content-Digest and Content-Length are missing) for handling very old/broken registries.

In fact, such flow isn't even allowed per spec:

A HEAD request to an existing blob or manifest URL MUST return 200 OK. A successful response MUST contain the digest of the uploaded blob or manifest in the header Docker-Content-Digest. A successful response MUST contain the size in bytes of the uploaded blob or manifest
in the header Content-Length.

A GET request to an existing manifest URL MUST provide the expected manifest, with a response code that MUST be 200 OK. A successful response MUST contain the digest of the uploaded blob in the header Docker-Content-Digest.

(per https://github.com/opencontainers/distribution-spec/blob/main/spec.md#checking-if-content-exists-in-the-registry)

I think it's not worth bloating this even more.

@vvoland
vvoland requested a review from samuelkarp April 30, 2026 16:54
@dmcgowan dmcgowan added this to the 2.4 milestone May 11, 2026
@dmcgowan dmcgowan moved this from Needs Reviewers to Review In Progress in Pull Request Review May 11, 2026
@k8s-ci-robot

Copy link
Copy Markdown

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@thaJeztah

Copy link
Copy Markdown
Member

@vvoland can you rebase?

According to the OCI distribution spec registries may include
informational warnings in HTTP Warning headers:

- https://github.com/opencontainers/distribution-spec/blob/e612a6e1e1bc717f9fa7e1feb4f05c8b6568754a/spec.md#warnings
- https://www.rfc-editor.org/rfc/rfc7234#section-5.5

This change implements support for handling these warnings and
propagating them to the resolver.

This patch adds a new, optional WarningHandler interface field to
ResolverOptions that allows callers to receive and process warnings sent
by registries via HTTP Warning headers with warn-code 299.

Signed-off-by: Paweł Gronowski <[email protected]>
Copilot AI review requested due to automatic review settings July 13, 2026 10:16
@vvoland

vvoland commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased and squashed

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@mxpv
mxpv added this pull request to the merge queue Aug 5, 2026
Merged via the queue into containerd:main with commit 468924e Aug 5, 2026
87 of 90 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 5, 2026
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
containerd 2.4.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>Welcome to the v2.4.0 release of containerd!

containerd 2.4 is a regular (non-LTS) release with a shorter support window,
intended for users who want to adopt new features sooner. As the release
following the 2.3 LTS, it is the point in the release cycle where previously
deprecated features may be removed, so this release may include breaking
changes; check the notes below and clear any deprecation warnings from your
current version before upgrading.

Users prioritizing stability and a longer support lifecycle should stay on the
2.3 LTS release.

### Highlights

#### Container Runtime Interface (CRI)

* Enable mount manager for image mounts in CRI ([#13542](containerd/containerd#13542))
* Export sandbox image and CNI directory configuration in CRI plugin info ([#13940](containerd/containerd#13940))
* Set default runtimeFeatures.UserNamespacesHostNetwork to true ([#13162](containerd/containerd#13162))
* Support OCI runtime feature introspection for non-runc runtimes ([#13504](containerd/containerd#13504))

#### Image Distribution

* Apply hardening to strip sensitive authentication headers when fetching descriptor URLs ([#12889](containerd/containerd#12889))
* Support propagating HTTP 299 warning headers from registries to the resolver ([#12698](containerd/containerd#12698))
* Use klauspost/compress for gzip layer decompression ([#13560](containerd/containerd#13560))

#### Image Storage

* Add client options to fetch all layer content during unpack even when snapshots exist ([#14126](containerd/containerd#14126))
* Include media type in content create events ([#13833](containerd/containerd#13833))
* Add forward References to the GC collection context ([#13634](containerd/containerd#13634))

#### Node Resource Interface (NRI)

* Expose container image name, digest, and config digest to NRI plugins ([#13960](containerd/containerd#13960))
* Emit deprecation warnings for plugins using deprecated NRI interfaces ([#13916](containerd/containerd#13916))

#### Runtime

* Mask /proc/interrupts and CPU thermal throttle sysfs paths in Linux containers by default ([#14090](containerd/containerd#14090))
* Add UpdateSandbox RPC to propagate sandbox controller updates to the shim ([#14105](containerd/containerd#14105))
* Avoid immediately restarting containers with restart=always policy after they are explicitly stopped ([#13993](containerd/containerd#13993))
* Pass tracing context from shim to runc and hooks ([#14036](containerd/containerd#14036))
* Fix user and group lookup failures in container rootfs containing symlinked /etc/passwd or /etc/group ([#13818](containerd/containerd#13818))
* Implement Windows named-pipe server and log streaming support in pkg/shim ([#13948](containerd/containerd#13948))
* Enable log scrubbing by default on Windows ([#13837](containerd/containerd#13837))
* Allow specifying parent checkpoint directory when checkpointing with runc ([#13699](containerd/containerd#13699))

#### Snapshotters

* Add Prometheus metrics for EROFS snapshotter layer content cache ([#13941](containerd/containerd#13941))
* Support warm image cache for erofs snapshotter ([#13813](containerd/containerd#13813))
* Add max size label for snapshots ([#13520](containerd/containerd#13520))

#### Breaking

* Remove deprecated CRI and tracing configuration options:
  * Remove `enable_cdi` in CRI runtime configuration (CDI is now always enabled)
  * Remove `bin_dir` in CRI CNI configuration (use `bin_dirs`)
  * Remove `endpoint`, `protocol`, and `insecure` in OTLP tracing processor configuration (use standard OTLP environment variables)
  * Remove `service_name` and `sampling_ratio` in internal tracing configuration (use standard OpenTelemetry environment variables) ([#14166](containerd/containerd#14166))
* Remove restore in CreateContainer ([#13871](containerd/containerd#13871))

#### Deprecations

* Deprecate containerd.io/runtime-allow-mounts shim annotation in favor of MountCapabilities bootstrap extension ([#14002](containerd/containerd#14002))
* Remove deprecated shim.Command from pkg ([#13991](containerd/containerd#13991))
* Deprecate task API address and version fields in runc options and move to CreateTaskRequest ([#13360](containerd/containerd#13360))

Please try out the release binaries and report any issues at
https://github.com/containerd/containerd/issues.

### Contributors

* Maksym Pavlenko
* Sebastiaan van Stijn
* Samuel Karp
* Derek McGowan
* Wei Fu
* Akihiro Suda
* Mike Brown
* Paweł Gronowski
* Chris Henzie
* Phil Estes
* Brian Goff
* Austin Vazquez
* ningmingxiao
* Jordan Liggitt
* Akhil Mohan
* Eshaan Mathur
* Krisztian Litkey
* Chris Ayoub
* Kazuyoshi Kato
* Kir Kolyshkin
* Sergey Kanzhelev
* Ahmet Alp Balkan
* Arpit Jain
* Cindy Li
* Damien Grisonnet
* Esteban Ginez
* Gao Xiang
* Harsh Rawat
* Laura Lorenz
* Maksim An
* Oleh Konko
* Philip Laine
* Abhishek Bhunia
* Alan Grosskurth
* Albin Kerouanton
* Alex Lyn
* Aman Raj
* Amir Alavi
* Amit Barve
* Andrew Halaney
* AprilNEA
* Arjun Yogidas
* Ayato Tokubi
* Aysha Afrah Ziya
* Ben Cressey
* Bing Hongtao
* Chris Crone
* Craig Gumbley
* Daniel De Graaf
* Davanum Srinivas
* Dr. Jan-Philip Gehrcke
* Harshal Patel
* Henry Wang
* Hsiu-Chi Tsai
* JP Phillips
* Jing Chen
* Kohei Tokunaga
* LEI WANG
* Martín Fernández
* Mikhail Dmitrichenko
* Nahum Litvin
* Nikolaus Schuetz
* Pablo Garcia Caceres
* Paco Xu
* Robert Cronin
* SaloniRathi
* Shambhavi Srivastava
* Tianon Gravi
* XlabAI
* Yuanliang Zhang
* ayush-panta
* crawfordxx
* cshung
* match man
* s3onghyun
* 归寂
* 徐晓伟

### Changes
<details><summary>658 commits</summary>
<p>

  * [`647fafa847`](containerd/containerd@647fafa) Prepare release notes for v2.4.0
* Prepare release notes for api/v1.12.0 ([#14170](containerd/containerd#14170))
  * [`5c4ea21de3`](containerd/containerd@5c4ea21) Prepare release notes for api/v1.12.0
* Deprecations and removals for 2.4 ([#14166](containerd/containerd#14166))
  * [`531b3a37b9`](containerd/containerd@531b3a3) tracing: remove deprecated tracing config options
  * [`ca8579a334`](containerd/containerd@ca8579a) tracing: add tests for otlp exporter and env vars
  * [`ee024b7c99`](containerd/containerd@ee024b7) tracing: remove deprecated otlp configs
  * [`f7c654fb4f`](containerd/containerd@f7c654f) cri: remove deprecated cni bin_dir
  * [`4f7de25abb`](containerd/containerd@4f7de25) cri: remove enable_cdi config option
  * [`830b48d3fd`](containerd/containerd@830b48d) cri: delay registry config removal to 2.7
* Prepare release notes for v2.4.0-rc.0 ([#14115](containerd/containerd#14115))
  * [`c02620e398`](containerd/containerd@c02620e) Prepare release notes for v2.4.0-rc.0
  * [`02c7c97f43`](containerd/containerd@02c7c97) Update release doc for 2.4.0 release
  * [`484e5aba58`](containerd/containerd@484e5ab) vendor: github.com/containerd/containerd/api v1.12.0-rc.1
  * [`67174d675c`](containerd/containerd@67174d6) mailmap: add Paweł Gronowski
* Update erofs snapshotter to record blob source ([#14107](containerd/containerd#14107))
  * [`697a7571a4`](containerd/containerd@697a757) erofs: give a dm-verity device a name unique to its mount
  * [`f75817eb3b`](containerd/containerd@f75817e) erofs: record where a layer blob is
  * [`d92088d822`](containerd/containerd@d92088d) erofs: refuse to apply into a read-only snapshot
  * [`8cc0b076a6`](containerd/containerd@8cc0b07) erofs: serve layer content cache on parented Prepare
* build(deps): bump the golang-x group with 4 updates ([#14150](containerd/containerd#14150))
  * [`75138b3fda`](containerd/containerd@75138b3) build(deps): bump the golang-x group with 4 updates
* build(deps): bump github.com/klauspost/compress from 1.19.2 to 1.20.0 ([#14153](containerd/containerd#14153))
  * [`353342cae6`](containerd/containerd@353342c) build(deps): bump github.com/klauspost/compress from 1.19.2 to 1.20.0
* pkg/oci: mask thermal interrupt info ([#14090](containerd/containerd#14090))
  * [`c176f185b0`](containerd/containerd@c176f185b08e14bde055d81dc509

See merge request: Harmonybrew/homebrew-core!20372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants