Skip to content

Overlay snapshotter should return overlayfs mount for parallel…#13044

Closed
henry118 wants to merge 2 commits intocontainerd:mainfrom
henry118:bug-13030
Closed

Overlay snapshotter should return overlayfs mount for parallel…#13044
henry118 wants to merge 2 commits intocontainerd:mainfrom
henry118:bug-13030

Conversation

@henry118
Copy link
Copy Markdown
Member

Fixes: #13030

During parallel unpack, "parent" is not passed in for snapshot prepare. The result is that overlay SN will return bind mounts instead of overlay mounts.

This PR introduces a label to indicate that the snapshot is to be "rebased" later. This will allow the overlay SN to return overlay mount. This way the whiteout files can be correctly handled by diff-apply logic.

This bug seems only apply to overlay. EROFS works fine based on my testing.

@dmcgowan
Copy link
Copy Markdown
Member

This bug seems only apply to overlay. EROFS works fine based on my testing.

That's because erofs uses its a different applier. If it used the default walking applier it would fail as well. Its probably cleaner to have the default walking applier not have any special logic and have different appliers for these use cases. Such as with #12842. Parallel unpack would only be used together with an unpack configuration that knew how to handle it and what differ to use anyway. Without that special logic, then it would just do serial unpack with the walking differ.

For backporting, this change is probably the smallest and best to get in though. I just don't think it is the cleaner long term solution.

@henry118
Copy link
Copy Markdown
Member Author

Ah I wasn't aware of #12842. I'll try to add an overlay specific applier on top of that work.

@samuelkarp
Copy link
Copy Markdown
Member

We should have an integration test around this too, reproing the reported issue.

@henry118
Copy link
Copy Markdown
Member Author

We should have an integration test around this too, reproing the reported issue.

Yes I have an integration test, but it requires a testing image. Currently the image is hosted on AWS ECR. It's better to be added to containerd's gchr. Could use some help with that as I don't have permission.

$ cat Dockerfile
FROM alpine

RUN touch /file-to-delete
RUN rm /file-to-delete

RUN mkdir /dir-to-delete && touch /dir-to-delete/foo
RUN rm -rf /dir-to-delete

@henry118 henry118 changed the title Overlay snapshotter should return overlayfs mount for during parallel… Overlay snapshotter should return overlayfs mount for parallel… Mar 17, 2026
@samuelkarp
Copy link
Copy Markdown
Member

Should we host the image in ghcr or just build it as part of the test? I think either is reasonable.

@samuelkarp samuelkarp added the cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch label Mar 17, 2026
@henry118
Copy link
Copy Markdown
Member Author

It would be great if the test image is held in ghcr. That'll greatly simplify the test implementation.

Other benefits include:

  • No runtime dependency on docker, buildx and buildkit (we have to build multi-arch image for both amd64 and arm)
  • Test image can be reused by multiple tests
  • The image has to be in registry to test the image pull workflow.

@samuelkarp
Copy link
Copy Markdown
Member

@henry118
Copy link
Copy Markdown
Member Author

Thanks @samuelkarp. The test is updated to use the ghcr image.

Copy link
Copy Markdown
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

Mostly looks good. One question about userns, a nit about the test, and some suggested comments to make it clearer to a future reader.

Comment thread integration/client/container_linux_test.go Outdated
Comment thread plugins/snapshots/overlay/plugin/plugin.go
Comment thread plugins/snapshots/overlay/overlay.go Outdated
Comment thread core/unpack/unpacker.go Outdated
// If we only have one layer/no parents then just return a bind mount as overlay
// will not work. The exception is parallel unpack initially has parentless layers
// that need to be rebased on a parent later. For this case, the "overlay" mount
// is returned to signal the optimized fast-path in the walking applier.
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.

I must admit that I don't actually follow on a quick read what the fast path / slow path for the walking applier is (that's just my shortcomings of internals here).

Does this trick work if we are doing a "parallel" unpack of a single layer image?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes single layer image will work:

  • The label is only applied to upper layers during unpack. A single layer of an image won't be labeled and will follow the slow-path (tmp mount);
  • However, we can execute the fast-path for single layer too, because the fast-path doesn't really need the parents to apply the layer content.

I chose to implement the 1st approach in this PR to align more closely with the existing logic.

for i := range s.ParentIDs {
parentPaths[i] = o.upperPath(s.ParentIDs[i])
}
options = append(options, fmt.Sprintf("lowerdir=%s", strings.Join(parentPaths, ":")))
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.

kernel will post error like overlay: Bad value for 'lowerdir' if parentPaths is empty.
I am thinking we can use grpc metadata (just like namespace) wrapper and pass option to differ and then it can pick up whiteout converter.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think this problem would happen per the current logic.
This malformed mount option is only used by the fast-path of the applier logic during unpacking.
Regular mount operations will always have parents due to rebase.

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.

Happy path is always happy. I mean it's trying to poke hole as label can be updated by API.
Just feel like it's short-term fix but poke hole of system. I am not against introducing API-level change on applier

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm working on #13053 as long term fix.

Any chance this PR get in for v2.2 back-port in the interim?

Comment thread core/unpack/unpacker.go Outdated
}
snapshotLabels[labelSnapshotRef] = chainID

if i > 0 && parallel {
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.

or tweak the mount info if's overlay snapshot (it's hack)

@fuweid
Copy link
Copy Markdown
Member

fuweid commented Mar 24, 2026

The change can work. But I still think we should let snapshot return correct mount information and client side can tweak that to let applier to use whiteout converter. Let other reviewers chime in as well.

@henry118
Copy link
Copy Markdown
Member Author

The change can work. But I still think we should let snapshot return correct mount information and client side can tweak that to let applier to use whiteout converter. Let other reviewers chime in as well.

@fuweid I implemented the alternative solution in #13115. Does it align what you've been thinking?

@henry118
Copy link
Copy Markdown
Member Author

I also rebased this PR and got rid of the original label proposed in this PR.

We can just reuse the label introduced by #13071.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Mar 24, 2026
@henry118
Copy link
Copy Markdown
Member Author

#13115 was merged. closing this.

@henry118 henry118 closed this Mar 25, 2026
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Mar 25, 2026
@henry118 henry118 deleted the bug-13030 branch March 26, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch kind/bug size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

whiteout files not honored by max_concurrent_unpacks > 1

6 participants