Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Propagates CRI per-container snapshot configuration to snapshotters by inheriting containerd.io/snapshot/* labels from container annotations when preparing the container rootfs snapshot, matching the existing pod sandbox snapshot behavior.
Changes:
- Introduce
snapshotOpts()to prepend inherited snapshot labels (from container annotations) ahead of platform-specific snapshot options. - Switch container creation to use
snapshotOpts()instead of calling platform-specificsnapshotterOpts()directly. - Add unit tests validating label inheritance/filtering behavior for container snapshot options.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/cri/server/container_create.go | Adds snapshotOpts() and uses it during container snapshot preparation to inherit snapshot labels from annotations. |
| internal/cri/server/container_create_test.go | Adds tests for snapshotOpts() to ensure only snapshot-label annotations are propagated. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
CriDriver reported no disk quota support, so `disk` was refused on every CRI node and, with nothing asking for one, a container's writable layer had no bound at all: one tenant could fill the node's disk. containerd can enforce it per container, but only through the erofs snapshotter, which sizes the writable layer by allocating a fixed-size filesystem image for it. It reads the size from the containerd.io/snapshot/max-size snapshot label, and that label reaches a CRI container as an annotation. Report support by asking the runtime which snapshotter it prepares this node's rootfs with, rather than by a setting an operator would have to keep in step with containerd. The snapshotter is chosen per runtime handler -- containerd ships kata-fc on devmapper beside handlers left on overlayfs -- so the question is asked for the handler this node is configured to use, and CRI Status carries the runtime's own config, the same source _available_runtimes() already reads. Anything that is not erofs, including a handler falling through to a default Status does not report, reads as no quota. That keeps the existing refusal for those nodes, which is the honest answer: a `disk` accepted and then not applied is worse than one turned down, because nothing tells the tenant. Requires containerd to pass the annotation through to the container snapshot, which today it does only for the sandbox (containerd/containerd#14070).
The sandbox snapshot inherits `containerd.io/snapshot/*` labels from the sandbox annotations (see podsandbox.sandbox_run), but the container's rootfs snapshot takes nothing from the container annotations, so the writable layer cannot be sized per container. On Windows the CRI API carries WindowsContainerResources.rootfs_size_in_bytes and containerd translates it into a snapshot label. There is no Linux equivalent in the CRI API, so an annotation is the only channel available. Take containerd.io/snapshot/max-size from the container annotations and pass it to the snapshotter, ahead of the platform specific options. Only that label is taken, rather than every containerd.io/snapshot/ annotation as the sandbox does: the other labels under the prefix are containerd's own, and the user namespace ID mappings in particular are set by snapshotterOpts only when a user namespace is requested, so an inherited mapping would otherwise reach the snapshotter unchallenged for a container that has none. With the erofs snapshotter, a container annotated with containerd.io/snapshot/max-size=33554432 gets a 32MiB writable layer and writes past it fail with ENOSPC, while an unannotated container in the same pod still gets the snapshotter's configured default. Signed-off-by: Simon Zhou <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
87d07c2 to
73b1c9c
Compare
|
Thanks @hsiangkao — agreed, and I think the narrower form is the safer one rather than just the smaller one. Inheriting the whole Pushed a new revision that takes only Sorry for invalidating the approval — PTAL. |
There was a problem hiding this comment.
🟡 Changes recommended
Filtered container annotations must be forwarded to satisfy the stated snapshot-label inheritance contract.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
| if size, ok := config.GetAnnotations()[snapshots.LabelSnapshotMaxSize]; ok { | ||
| opts = append(opts, snapshots.WithLabels(map[string]string{ | ||
| snapshots.LabelSnapshotMaxSize: size, | ||
| })) | ||
| } |
The CRI nodes run a containerd built from this fork's main, because the erofs writable-layer size and the containerd.io/snapshot/max-size label exist only on upstream main, in no release yet, and the CRI change that carries the label (containerd#14070) is not merged. Every push to main now builds linux/amd64 and linux/arm64 with upstream's release Dockerfile and publishes a prerelease tagged with the upstream version, the date and the commit, so a node is pinned to an exact build and `containerd --version` names it. Co-authored-by: Claude Fable 5.1 <[email protected]>
The CRI nodes run a containerd built from this fork's main, because the erofs writable-layer size and the containerd.io/snapshot/max-size label exist only on upstream main, in no release yet, and the CRI change that carries the label (containerd#14070) is not merged. Every push to main now builds linux/amd64 and linux/arm64 with upstream's release Dockerfile and publishes a prerelease tagged with the upstream version, the date and the commit, so a node is pinned to an exact build and `containerd --version` names it. Co-authored-by: Claude Fable 5.1 <[email protected]>
The CRI nodes run a containerd built from this fork's main, because the erofs writable-layer size and the containerd.io/snapshot/max-size label exist only on upstream main, in no release yet, and the CRI change that carries the label (containerd#14070) is not merged. Every push to main now builds linux/amd64 and linux/arm64 with upstream's release Dockerfile and publishes a prerelease tagged with the upstream version, the date and the commit, so a node is pinned to an exact build and `containerd --version` names it. Co-authored-by: Claude Fable 5.1 <[email protected]>
The CRI nodes run a containerd built from this fork's main, because the erofs writable-layer size and the containerd.io/snapshot/max-size label exist only on upstream main, in no release yet, and the CRI change that carries the label (containerd#14070) is not merged. Built daily and on every push to main with upstream's release Dockerfile for linux/amd64 and linux/arm64, published as one prerelease per day tagged main.<yyyymmdd>: a second build the same day replaces the day's release, a day on which main did not move is skipped, and the last 30 are kept. `containerd --version` reports the tag and the commit. Co-authored-by: Claude Fable 5.1 <[email protected]>
layerSnapshotLabels() strips containerd.io/snapshot/uidmapping and .../gidmapping from image manifest annotations because snapshotters act on them during Prepare (containerd#13855). Complete the enumeration with .../max-size, added in containerd#13520: the erofs snapshotter honors it unclamped when sizing the writable layer of an active snapshot (writableSize -> X-containerd.mkfs.size -> truncate + mkfs.ext4), and an image manifest is not a trusted source for that host-side resource decision. The sanctioned setters of max-size are CRI clients, via PodSandboxConfig annotations on the sandbox path (to be extended to container annotations in containerd#14070); those are untouched. Today the in-tree erofs differ locates the layer directory through the mount list without materializing the writable image (MountsToLayer), so no current code path turns an image-supplied max-size into a real allocation — this is defense-in-depth completing containerd#13855's enumeration before any consumer of unpack-time layer mounts does. Signed-off-by: pandaWall <[email protected]>
layerSnapshotLabels() strips containerd.io/snapshot/uidmapping and .../gidmapping from image manifest annotations because snapshotters act on them during Prepare (containerd#13855). Complete the enumeration with .../max-size, added in containerd#13520: the erofs snapshotter honors it unclamped when sizing the writable layer of an active snapshot (writableSize -> X-containerd.mkfs.size -> truncate + mkfs.ext4), and an image manifest is not a trusted source for that host-side resource decision. The sanctioned setters of max-size are CRI clients, via PodSandboxConfig annotations on the sandbox path (to be extended to container annotations in containerd#14070); those are untouched. Today the in-tree erofs differ locates the layer directory through the mount list without materializing the writable image (MountsToLayer), so no current code path turns an image-supplied max-size into a real allocation — this is defense-in-depth completing containerd#13855's enumeration before any consumer of unpack-time layer mounts does. Signed-off-by: pandaWall <[email protected]>
The branch carries 73b1c9c, the same change as 9c24548 already on main (containerd#14070); the merge changes no file.
|
PR needs rebase. DetailsInstructions 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. |
The sandbox snapshot inherits
containerd.io/snapshot/*labels from the sandbox annotations (podsandbox.sandbox_run), but the container's rootfs snapshot takes nothing from the container annotations, so the writable layer cannot be sized per container.On Windows the CRI API carries
WindowsContainerResources.rootfs_size_in_bytesand containerd translates it into a snapshot label. There is no Linux equivalent in the CRI API, so an annotation is the only channel available.This takes
containerd.io/snapshot/max-sizefrom the container annotations and passes it to the snapshotter, ahead of the platform specific options. Only that label is taken, rather than everycontainerd.io/snapshot/annotation as the sandbox does (as suggested in review): the other labels under the prefix are containerd's own, and the user namespace ID mappings in particular are set bysnapshotterOptsonly when a user namespace is requested, so an inherited mapping would otherwise reach the snapshotter unchallenged for a container that has none.Verified on the erofs snapshotter (
default_size = '512M'), three containers in one pod:df -h /dd bs=1M count=64max-size: "33554432"max-sizeonlymax-size+uidmapping/gidmapping(no user namespace requested)0:0max-sizeonly