Commit Graph
400 Commits
Author SHA1 Message Date
Fu Wei 1335870fbc Merge pull request #14057 from thaJeztah/rm_stray_logrus_imports
plugins: remove some stray logrus imports
2026-08-28 02:01:29 +00:00
Fu Wei 0d966372d6 Merge pull request #14012 from crunchloop/erofs-snapshotter-os-feature
snapshots/erofs: advertise the erofs OS feature from the snapshotter plugin
2026-08-28 01:51:40 +00:00
Sebastiaan van Stijn b845501327 plugins: remove some stray logrus imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-27 22:44:35 +02:00
Martín Fernández 988f113ab7 snapshots/erofs: test the advertised erofs feature platform
The preceding commit advertises the default platform with the erofs OS feature. Move construction of that platform set into snapshotterPlatforms so the client-side matching contract can be tested without changing the advertisement.

EROFS identifies the image layer package format rather than a Linux-only host capability, so the feature-bearing entry remains derived from platforms.DefaultSpec. Test that the advertised set matches both the plain default platform and the same platform carrying the erofs feature.

Assisted-by: Claude Opus 5

Signed-off-by: Martín Fernández <mfernandez@crunchloop.io>
2026-08-27 15:07:35 -03:00
Maksym Pavlenko f63e9b80de Merge pull request #13941 from mxpv/erofs-metrics
erofs: instrument warm up cache
2026-08-25 16:29:01 +00:00
Derek McGowan 5e083f8d43 erofs: advertise the erofs OS feature platform from the snapshotter
Advertise a second platform - the default platform spec with OSFeatures
["erofs"] - from the EROFS snapshotter plugin, alongside the plain
default platform it already advertised. This mirrors what the EROFS
differ plugin already advertises.

This is required by client.Image.Unpack's checkSnapshotterSupport, which
rejects unpacking an image whose config declares os.features onto a
snapshotter that doesn't advertise a matching platform: without this,
pulling and unpacking an EROFS image layer format specification image
(https://github.com/erofs/erofs-image-spec) - which requires "erofs" in
os.features - with the erofs snapshotter would fail that check.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Martín Fernández <mfernandez@crunchloop.io>
2026-08-23 20:32:50 -03:00
Philip Laine 93f38adbca Export config in CRI plugin
Signed-off-by: Philip Laine <philip.laine@gmail.com>
2026-08-17 10:50:51 +02:00
Maksym Pavlenko 81c272b28d erofs: instrument the layer content cache and applies
There was no way to tell whether a cache was doing anything: hits and
misses were only visible as trace log lines. Count lookups by result,
hits by the directory that served them so caches with different lifetimes
can be told apart, the blob bytes served, and lookup errors by reason,
which also makes an unreadable cache (a down FUSE mount, say) visible
instead of looking like a cold one.

Also add a span around the differ's Apply, carrying the layer descriptor
and which path handled it. The unpacker traces the fetch and the layer
lifecycle but not the apply, so a slow layer couldn't be pinned on the
download or the conversion.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-08-11 12:19:46 -07:00
Chris Ayoub e940b5ac18 snapshots/erofs: protect snapshot staging from cleanup
A new-* directory can exist before createSnapshot acquires the metadata
writer transaction. A concurrent Remove performs a global orphan scan and
can delete the staging directory because it is not in the ID map yet.

Exclude new-* staging directories from orphan cleanup and use a shared
local constant for directory creation and filtering.

Signed-off-by: Chris Ayoub <cayoub@openai.com>
2026-08-10 03:43:49 +00:00
Krisztian Litkey bf0111a9cc nri,deprecation: emit warnings for old NRI plugins.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2026-08-07 10:39:30 -05:00
Maksym Pavlenko 7df6bb0a67 erofs: allow multiple layer content cache directories
The layer content cache was a single directory, so every source of
pre-converted blobs had to be merged into one tree. A shared read-only fleet
cache, a host-local cache, and a per-image warm cache could not coexist.

Replace layer_content_cache with layer_content_caches, a list. Each directory
is checked in order and the first hit is staged into the snapshot; a layer
found in none of them falls back to the normal download-and-convert path.

Cache directories are no longer required to exist at startup. A missing one is
indistinguishable from an empty one at lookup time (both are simply a miss),
and it may well be mounted after the daemon starts, so the only check left is
that each path is absolute -- a relative one would be symlinked into the
snapshot dir and dangle.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-08-03 13:14:44 -07:00
Maksym Pavlenko 1a34bf320a Merge pull request #13826 from mxpv/cache-parallel
erofs: enable parallel unpack with content cache
2026-08-03 19:28:09 +00:00
Maksym Pavlenko 257a5900b0 core/unpack: detect staged layers via read-only mounts
Replace the snapshots.ErrAlreadyStaged sentinel error with a
read-only-mounts signal: a snapshotter (e.g. erofs serving a layer
content cache hit) now returns Prepare mounts normally, with no
error, when the layer content is already staged into the active
snapshot. The unpacker's isStaged helper checks the last mount's
ReadOnly() to decide whether to skip fetch+apply and just commit.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-31 09:18:16 -07:00
Maksym Pavlenko 1e001e6dfe erofs: make the layer content cache work with parallel unpack
The cache used to serve a hit by committing the layer during Prepare and
returning ErrAlreadyExists, which is incompatible with parallel unpacking:
the "rebase" capability defers the parent to Commit time, so a
commit-at-Prepare layer ends up parentless. The erofs snapshotter therefore
had to disable rebase whenever the cache was enabled, making every cache
*miss* fall back to a fully sequential (slower-than-cold) pull.

Introduce snapshots.ErrAlreadyStaged, returned from Prepare to mean "the
active snapshot's content is staged; skip the layer download and apply, but
still Commit it" (where the parent is applied). Unlike ErrAlreadyExists it
does not end the layer's lifecycle. The unpacker handles it by emitting a
status whose bottom half runs the normal serialized commit (rebasing the
parent in), and the metadata snapshotter threads it through Prepare like a
normal active snapshot. The erofs cache hit now stages the blob and returns
ErrAlreadyStaged instead of committing, so it can advertise "rebase"
unconditionally: hits skip download+conversion and misses stay parallel.

Also promote the "rebase" capability string to snapshots.RebaseCap (shared by
the unpacker, erofs, and overlay).

Follow up:  fetch is range-based, so only a fully cached contiguous
prefix skips downloads; a miss in a lower layer still pulls everything above
it. Per-layer fetch-skip is left as a follow-up.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-31 09:18:15 -07:00
Fu Wei 9013f8cbae Merge pull request #13860 from dmcgowan/fix-erofs-mixed-merged
snapshots/erofs: keep lowers stacked above a merged fsmeta
2026-07-30 17:06:25 +00:00
Samuel Karp a3f99ba690 cri: deprecate restore in CreateContainer
Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-07-27 22:11:29 -07:00
Derek McGowan 01f5087866 snapshots/erofs: keep lowers stacked above a merged fsmeta
mounts() moved `first` to the merged fsmeta mount's index whenever
mountFsMeta matched, collapsing the overlay's lowerdir range to the
fsmeta alone and dropping any plain lowers already appended above it.

When fsmerge was added, fsmeta was only ever written for the top
parent of the chain being prepared, so the loop matched at i == 0,
where first already equalled the fsmeta's index and the reassignment
was a no-op. It only mattered once the fsmeta could sit below the top
parent, i.e. a chain extending an already-merged sub-chain. The
snapshotter no longer generates fsmeta itself, so today this only
affects externally supplied fsmeta files.

first only marks the start of the lowerdir range, so it must stay at
the first lower's index.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-07-27 12:02:38 -07:00
Maksym Pavlenko 82a47efe92 Support dmverity
Add a --dmverity flag to `ctr images build-erofs-cache`. When set, each cached
erofs blob is dm-verity formatted (the hash tree is appended in place) and a
.dmverity sidecar is written alongside it. This is required when the erofs
snapshotter runs with dmverity_mode=on, which rejects cache hits that lack a
sidecar; without it such layers would have to be formatted out-of-band.

Extract the differ's dm-verity formatting into a shared dmverity.FormatLayer so
the differ and the cache builder share one implementation; the differ's
formatDmverityLayer now delegates to it.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-21 10:07:08 -07:00
Maksym Pavlenko 728093bdca snapshots/erofs: source pre-converted layers from a content cache
Add a layer_content_cache option to the erofs snapshotter: a directory of
pre-converted, diffID-keyed erofs layer blobs (in production a read-only
mountpoint-s3/FUSE mount) that the snapshotter sources layers from on pull
instead of downloading and converting them per node.

On an image-layer extraction Prepare, if the layer's blob is present in the
cache the snapshotter stages it as a symlink, commits it as the target
chainID in the same transaction, and returns ErrAlreadyExists. This uses the
existing remote-snapshot protocol, so containerd skips both the layer
download and the tar->erofs conversion; no core changes are needed. Any miss
(cache disabled, no snapshot.ref/diff-id labels, blob absent, unreadable
cache) falls through to the normal path, so pulls keep working.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-07-21 09:43:41 -07:00
AprilNEA 5e25f36e5e overlay: don't override a configured index mount option
NewSnapshotter auto-appends "index=off" unless the configured
mount_options already carry an index option — but the check used
hasOption(..., "index", false), which compares against the literal
string "index". No valid mount option ever equals "index" (it is
always valued, "index=on"/"index=off"), so the append happened
unconditionally whenever the kernel exposes the overlay index
parameter.

Mount options are last-wins in the kernel, so a user-configured
"index=on" was silently overridden. Worse, configuring
mount_options = ["index=on", "nfs_export=on"] (the documented way to
make overlay mounts NFS-exportable) produced
"index=on,nfs_export=on,index=off", which the kernel rejects with
EINVAL (nfs_export=on conflicts with an explicit index=off) — breaking
every snapshot mount including image unpack.

Make hasOption match the key of a "key[=value]" option so callers need
not care whether the option takes a value, and add a regression test.

Signed-off-by: AprilNEA <github@sku.moe>
2026-07-17 16:04:32 +08:00
Samuel Karp 4a5b0733f5 Merge pull request #13469 from anmaxvl/blockcim-pull-fix
blockcim config and plugin initialization changes
2026-07-14 18:06:28 +00:00
Samuel Karp cb66686cbb Merge pull request #13664 from samuelkarp/criu-check-fail-fast
Disable checkpoint restore codepath when CRIU is not installed
2026-07-08 06:10:01 +00:00
Wei Fu 0b7466980e *: disable bbolt stat usage
Disable stat usage since we never consume the data.
This can reduce unnecessary contention during transactions.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2026-07-04 12:08:50 -04:00
Samuel Karp 186397511b cri: validate CRIU availability and version early
Perform an early validation check on both container checkpoint and
restore paths to fail-fast if the CRIU binary is missing or is older
than the minimum required version (3.16.0).

To support runtime-configured environments, the validation respects the
custom PATH from the shim manager environment if configured, skipping
any relative paths to avoid incorrect daemon-relative resolution. If not
configured, it falls back to a standard system PATH lookup. The check
result is cached using sync.Once to prevent redundant process spawning.

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-06-30 12:35:16 -07:00
Maksym Pavlenko 484c12c6ea Merge pull request #13633 from grey3228/fix/snapshotter_nil_deref
snapshots/devmapper: avoid nil status deref after mkfs failure
2026-06-26 16:29:42 +00:00
Maksim An 5ae5d993e6 use IsBlockCimWriteSupported for block CIM plugin init checks
Switch block CIM snapshotter and diff plugin init checks from
IsBlockCimSupported() to IsBlockCimWriteSupported() to allow plugins
to load when the CimWriter.dll is available, even on OS builds
without native block CIM support.

Signed-off-by: Maksim An <maksiman@microsoft.com>
2026-06-25 00:51:46 -07:00
Amit Barve 8fbeab28d2 Fix incorrect default config value for block CIM snapshotter
This change updates an incorrect default config value for the block CIM
snapshotter. The `ntfsFormat` should always be false for the block CIM
snapshotter. If the scratch needs to be formatted with NTFS, a format
option named `WithNTFSFormat` can be provided.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
2026-06-25 00:51:46 -07:00
Maksym Pavlenko ef8a596035 Merge pull request #13329 from ayush-panta/fix-flaky-windows-test-content-client
content: handle sharing violations on Windows
2026-06-25 04:37:07 +00:00
Mikhail Dmitrichenko 5e38aadc53 snapshots/devmapper: avoid nil status deref after mkfs failure
dmsetup.Status() returns a nil DeviceStatus when it fails.  The mkfs
failure path records that error, but still unconditionally dereferences
status when logging the pool status.

Avoid the panic by logging a fallback status string when dmsetup.Status()
does not return a status.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
2026-06-19 14:16:49 +03:00
Derek McGowan f2b7791b23 Add max size label for snapshots
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-06-02 15:23:27 -07:00
ayush-panta a26143af1e content: handle sharing violations on Windows
On Windows, os.RemoveAll and os.ReadFile can fail with a sharing
violation when a file handle has not been fully released by the OS.
Unlike Unix, Windows does not allow deleting or reading a file
while any handle is open, and handles may be held briefly after
Close returns. This causes a race between the gRPC server-side
writer Close (which writes updatedat.tmp) and both Abort (which
calls RemoveAll on the ingest directory) and status (which reads
the updatedat file), surfacing as a flaky
TestContentClient/CommitErrorState on Windows CI.

Add platform-specific removePath and readFileWithRetry helpers
that retry with incremental backoff on Windows. On non-Windows
platforms they pass through to os.RemoveAll and os.ReadFile
directly. This follows the same pattern as ensureRemoveAll in
the CRI server helpers, which retries on EBUSY for mount races
on Linux.

Signed-off-by: ayush-panta <ayushkp@amazon.com>
2026-06-01 08:08:14 -07:00
Samuel Karp ae843af785 Merge pull request #13360 from mxpv/task
Fix sandbox task API endpoints for non-runc runtimes
2026-05-19 00:15:24 +00:00
Maksym Pavlenko b88ab5af4f Wire task address and version fields
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-05-18 13:37:19 -07:00
Derek McGowan 0ed0ec0d41 Merge pull request #13389 from AkihiroSuda/fix-13388
overlay: disable "rebase" capability when running in UserNS
2026-05-12 19:12:20 +00:00
Akihiro Suda 65d75e997b overlay: disable "rebase" capability when running in UserNS
Fix issue 13388

```
[...]
May 12 16:57:23 kind-control-plane kubelet[257]:         failed to extract layer (application/vnd.docker.image.rootfs
.diff.tar sha256:6f1cdceb6a3146f0ccb986521156bef8a422cdbb0863396f7f751f575ba308f4) to overlayfs as "extract-920875437
-7QPF sha256:31e64620332e54e3e4fb246d8325ed2c9f1c2cc64a95f0bb23b4b7e82834c95a": failed to mount /var/lib/containerd/t
mpmounts/containerd-mount2180142388: mount source: "overlay", target: "/var/lib/containerd/tmpmounts/containerd-mount
2180142388", fstype: overlay, flags: 0, data: "upperdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/sn
apshots/279/fs", err: invalid argument
[...]
```

This was a regression introduced in PR 13115.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-05-13 02:47:23 +09:00
Derek McGowan ccfcb15761 Merge pull request #13363 from AkihiroSuda/fix-13362-rootless-grpc-server
server: tolerate failed gRPC plugins when starting listeners
2026-05-12 17:10:19 +00:00
Akihiro SudaandClaude Opus 4.7 ef985f8628 server: tolerate failed gRPC plugins when starting listeners
The grpc, grpc-tcp, and ttrpc server plugins enumerated their services
through ic.GetByType, which short-circuits on the first plugin whose
Instance() returned an error. A single failed gRPC plugin (e.g. CRI
under rootless, which cannot watch /etc/cni/net.d) therefore prevented
the server plugins from initialising, leaving /run/containerd/containerd.sock
uncreated.

Iterate the plugin set directly and skip plugins that failed to
initialise, restoring the pre-c15ec2485 behaviour where the listener
is still created and only the failed services are missing.

Fixes: c15ec2485 ("Add server plugins for grpc and ttrpc")
Fixes: https://github.com/containerd/containerd/issues/13362

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-05-10 14:02:25 +09:00
Brian Goff f8a5f8d2c0 Refactor transfer unpack configuration setup
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2026-05-04 11:42:17 -07:00
Brian Goff 5860534c35 Fix optional transfer differ setup
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2026-05-04 11:41:34 -07:00
Derek McGowan b7f8c3510d erofs: remove fsmerge threshold from snapshotter
Currently the metadata may be generated after a snapshot is committed,
causing a difference in the overlayfs mount that may cause ESTALE errors.
The committed snapshot must be immutable and should always return the
same set of mounts after commit, even if configuration is changed.

This setting may be added back later to be performed before commit,
either as part of the unpack or as a step before commit. This is getting
pulled out from the upcoming release.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-29 16:26:45 -07:00
Fu Wei f9372eccf3 Merge pull request #13269 from Apokleos/erofs-dmverity-label
snapshotter/erofs: pass explicit dm-verity metadata path via mount options
2026-04-25 20:59:12 +00:00
Alex Lyn 31ca428580 snapshots/erofs: pass dm-verity metadata path via mount options
Update the EROFS snapshotter to pass the dm-verity metadata path
through the `X-containerd.dmverity` mount option. Previously, the
system relied on implicit mode detection; providing the explicit
path allows downstream components (such as Kata Containers mount
handlers) to reliably locate and read `.dmverity` files.

Correspondingly, update the EROFS mount handler to parse and utilize
this explicit metadata path for dm-verity device initialization.
This enables the runtime to retrieve root hashes and other necessary
metadata directly, ensuring robust layer integrity verification.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2026-04-25 18:34:57 +08:00
Samuel Karp 1919564f6c Merge pull request #13147 from tianon/sha512
Improve support for non-canonical digests (sha512, etc)
2026-04-22 23:04:22 +00:00
William Myers 557c54b116 sandbox: forward Create fields, fix event topics
The gRPC sandbox controller service only forwarded the `options` field
when calling the local controller. The `netns_path`, `rootfs`, and
`annotations` fields were silently dropped, causing clients using the
gRPC proxy path to receive incomplete sandbox configurations.

Event topics were missing the leading `/` prefix ("sandboxes/create"
instead of "/sandboxes/create"), causing the event exchange to reject
the publish and return an error to the caller.

Add unit tests for the controller service that exercise all RPC
methods.

Signed-off-by: William Myers <willmyrs@amazon.com>
2026-04-22 18:34:56 +00:00
Fu Wei 46a7bd7acb Merge pull request #12562 from dmcgowan/plugin-api-handlers
Add plugins for server listeners
2026-04-22 17:27:28 +00:00
Albin Kerouanton 4dc3d6d6f5 Default to euid/egid in ttrpc & grpc server plugins
Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
2026-04-21 18:03:10 -07:00
Derek McGowan a2b19072b8 Add metrics server plugin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:40 -07:00
Derek McGowan c15ec24857 Add server plugins for grpc and ttrpc
Migrate configuration and move server initialization

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:40 -07:00
Derek McGowan 06c23567c0 Add new server plugin type use for debug server
The new server plugin type allows services which have listeners to be
configured as plugins rather than defined directly in the global
configuration. This provides more configuration consistency and allows
containerd to be extended for new types of api handlers.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-21 18:02:00 -07:00
Tianon Gravi c5abec030a Add a warning when re-hash occurs during blob commit
(but only if the re-hash takes a "non-trivial" amount of time; currently hard-coded to 250ms)

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2026-04-21 13:17:19 -07:00