Skip to content

core/unpack: fetch layers of every config-sharing manifest - #13966

Merged
samuelkarp merged 1 commit into
containerd:mainfrom
chrishenzie:unpack-shared-config
Sep 9, 2026
Merged

samuelkarp merged 1 commit into
containerd:mainfrom
chrishenzie:unpack-shared-config

Conversation

@chrishenzie

@chrishenzie chrishenzie commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

An index can carry more than one manifest that shares a config. A config lists uncompressed layer digests, so packaging the same layers with different compression (which podman manifest push --add-compression does) produces manifests with identical configs and the same config digest.

Right now, when the unpacker visits a manifest, it stores its layers in a map keyed by its config's digest, so they can be unpacked later once the config descriptor is visited. Because that map holds only one manifest's layers per digest, when more than one manifest shares a config, only the last visited manifest's layers are stored (and unpacked), and the others' layers are never fetched. Image pulls still report success, but a later export or push of the image fails with NotFound.

Fix this by changing the map to store the layers for all manifests pointing at a specific config (instead of just one manifest). This means manifests sharing the same config result in more than one set of layers being stored for the same config digest. Because manifests that share a config unpack to the same snapshot chain, we only need to unpack the first manifest's layers, and fetch the others (so their blobs reach the content store). Unpack skips fetching a layer whose snapshot already exists, so once a second manifest shares the config, the first manifest's layers are also fetched explicitly; a config named by a single manifest keeps that skip. Note that for indexes with more than one config-sharing manifest, this will now result in additional download time and storage for those layers.

Don't store anything for a manifest with no layers; an empty slice reaching the unpack would fail the pull.

Fixes: #14000

Assisted-by: Claude Code

Ensure all layers are fetched when multiple manifests in an index share a config descriptor

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes an unpack/fetch edge case where multiple manifests share the same config digest (e.g., compression variants), ensuring all manifests’ layer blobs are fetched into the content store, and adds regression tests for shared-config and “manifest without layers” scenarios.

Changes:

  • Update Unpacker.Unpack to accumulate multiple layer sets per config digest and fetch additional sets when a shared config is encountered.
  • Ignore manifests that reach the unpacker with no layers (config-only after filtering) to avoid false diffID mismatches.
  • Add unit/integration tests covering shared-config manifests and config-only manifests.

Reviewed changes

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

File Description
core/unpack/unpacker.go Accumulates multiple manifest layer sets per shared config and fetches all sets; skips config-only manifests.
core/unpack/unpacker_test.go Adds regression tests for shared-config manifests and config-only manifests; introduces stub Snapshotter/Applier for fetch-only path.
core/unpack/pull_shared_config_test.go Adds end-to-end pull pipeline test to ensure all shared-config manifest layers are fetched from a local registry.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
@chrishenzie
chrishenzie marked this pull request as ready for review August 15, 2026 21:35
@fuweid fuweid self-assigned this Aug 17, 2026
@samuelkarp
samuelkarp requested a balanced review from Copilot August 19, 2026 00:14

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 3 out of 3 changed files in this pull request and generated no new comments.

@prakleumas prakleumas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

beep boop
Hello! I am @samuelkarp's friendly code review robot 🤖! Sam asked me to take a look and post my comments directly on GitHub.

Please treat my comments as suggestions and advisory, not mandates. Since I am an LLM and my output is used here directly, you should evaluate carefully and see if my suggestions make sense. Feel free to directly resolve any you disagree with.

This is not an automated action. This bot does not read or reply to comments.

Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/pull_shared_config_test.go Resolved
Comment thread core/unpack/pull_shared_config_test.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker_test.go Resolved
Comment thread core/unpack/unpacker_test.go Resolved
Comment thread core/unpack/unpacker_test.go Resolved
Comment thread core/unpack/unpacker_test.go Resolved
Comment thread core/unpack/unpacker_test.go Resolved
Copilot AI review requested due to automatic review settings August 20, 2026 18:50
@chrishenzie
chrishenzie force-pushed the unpack-shared-config branch from 943ed79 to fb66444 Compare August 20, 2026 18:50

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 3 out of 3 changed files in this pull request and generated no new comments.

@samuelkarp samuelkarp 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.

Can we update the PR description to clarify more about a "layer set" stored for a config? A config defines the layers by diffID (many per config) and we're talking about multiple separate manifests that reference the same config (and thus have identical unpacked layers), but I'm not sure exactly what we're discussing being stored there from that description alone. Are we storing all of the layers multiple times? Like, if manifest M1 defines layers L1, L2 and references config C1 (which has diffIDs for those layers), and then manifest M2 defines layers L1', L2' which are the same underlying layers (map to the same diffIDs) are we storing something like C1 -> [[L1, L2], [L1', L2']}?

Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Comment thread core/unpack/unpacker.go Resolved
Copilot AI review requested due to automatic review settings August 25, 2026 03:27
@chrishenzie
chrishenzie force-pushed the unpack-shared-config branch from fb66444 to dd85530 Compare August 25, 2026 03:27

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread core/unpack/unpacker.go Resolved
Copilot AI review requested due to automatic review settings August 25, 2026 17:22
@chrishenzie
chrishenzie force-pushed the unpack-shared-config branch from dd85530 to d604000 Compare August 25, 2026 17:22
An index can carry more than one manifest that shares a config. A config
lists uncompressed layer digests, so packaging the same layers with
different compression (which `podman manifest push --add-compression`
does) produces manifests with identical configs and the same config
digest.

Right now, when the unpacker visits a manifest, it stores its layers in
a map keyed by its config's digest, so they can be unpacked later once
the config descriptor is visited. Because that map holds only one
manifest's layers per digest, when more than one manifest shares a
config, only the last visited manifest's layers are stored (and
unpacked), and the others' layers are never fetched. Image pulls still
report success, but a later export or push of the image fails with
NotFound.

Fix this by changing the map to store the layers for all manifests
pointing at a specific config (instead of just one manifest). This means
manifests sharing the same config result in more than one set of layers
being stored for the same config digest. Because manifests that share a
config unpack to the same snapshot chain, we only need to unpack the
first manifest's layers, and fetch the others (so their blobs reach the
content store). Unpack skips fetching a layer whose snapshot already
exists, so once a second manifest shares the config, the first
manifest's layers are also fetched explicitly; a config named by a
single manifest keeps that skip. Note that for indexes with more than
one config-sharing manifest, this will now result in additional download
time and storage for those layers.

Don't store anything for a manifest with no layers; an empty slice
reaching the unpack would fail the pull.

Assisted-by: Claude Code
Signed-off-by: Chris Henzie <[email protected]>
Copilot AI review requested due to automatic review settings September 8, 2026 20:35

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.

🟡 Changes recommended

Concurrent unpack and fallback fetch operations can contend for the same content-store writer and fail the pull.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread core/unpack/unpacker.go Resolved
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Sep 9, 2026
@samuelkarp
samuelkarp added this pull request to the merge queue Sep 9, 2026
Merged via the queue into containerd:main with commit afa1524 Sep 9, 2026
97 of 100 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 9, 2026
@chrishenzie
chrishenzie deleted the unpack-shared-config branch September 9, 2026 23:49
@chrishenzie chrishenzie added cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels Sep 9, 2026
@chrishenzie

Copy link
Copy Markdown
Member Author

Cherry-picking manually due to conflicts

@samuelkarp samuelkarp added cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch impact/changelog area/storage Image Storage and removed cherry-pick/2.3.x Change to be cherry picked to release/2.3 cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch impact/changelog labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Image Storage cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-picked/2.0.x PR commits are cherry picked into the release/2.0 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Layers of config-sharing manifests are missing from the content store after pull

5 participants