Commit Graph

347 Commits

Author SHA1 Message Date
Gao Xiang
3b357da496 snapshotter/erofs: avoid using overlay if fsmerge is enabled and no upperdir
If fsmerge is enabled and no write is needed, it can return an overlay
mount with a single lowerdir, which is illegal for overlayfs.

For example, it can cause the following Nerdctl error:
 : I'm not sure why ctr works, but the issue is real.

```bash
$ nerdctl run --runtime io.containerd.kata.v2 --snapshotter=erofs -it --rm nginx:latest /bin/bash
FATA[0000] failed to mount {Type:overlay Source:overlay Target: Options:[lowerdir=/run/containerd/
io.containerd.mount-manager.v1.bolt/t/7/1]} on "/tmp/initialC2039543827": mount source: "overlay",
target: "/tmp/initialC2039543827", fstype: overlay, flags: 0, data: "lowerdir=/run/containerd/io.
containerd.mount-manager.v1.bolt/t/7/1", err: invalid argument
```

Switch to using a bind mount instead.

Fixes: 9a7500a974 ("Add support for EROFS fsmerge feature")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-13 17:52:29 +08:00
Fu Wei
997f813b5c Merge pull request #13185 from erofs/erofs-layers
erofs-differ: support zstd-wrapped EROFS layers
2026-04-12 22:20:11 +00:00
Gao Xiang
b9445fb9ef erofs-differ: support zstd-wrapped EROFS layers
Although EROFS has native compression support (and each filesystem can
contain multiple compression algorithms), in many cases, people only
consider using zstd compression when transporting on the wire in order
to reduce the pulling time but maintain the optimal runtime performance.

Only `+zstd` is considered: it has skippable frames which will be used
for the seekable EROFS implementation in future containerd versions.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-13 01:38:45 +08:00
Derek McGowan
a755ca16e5 Merge pull request #12865 from dmcgowan/readonly-overlay-erofs-no-mount
Support reading readonly overlays without mounting
2026-04-09 18:37:15 +00:00
Derek McGowan
0b164554be Merge pull request #13186 from erofs/walking_differ
diff/walking: enable mount manager
2026-04-09 15:35:08 +00:00
Gao Xiang
47cfd1138b diff/walking: enable mount manager
The default walking applier performs a real temporary mount for
unpacking, but the mount manager failed to adapt to the walking
differ.

This fixes the EROFS snapshotter together with the default walking
differ, otherwise it reports:

```
ctr: apply layer error for "[]": failed to extract layer sha256:[]:
failed to mount /var/lib/containerd/tmpmounts/containerd-mount3992073457:
internal mount option "X-containerd.mkfs.fs=ext4" was not consumed by
the mount manager
```

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-09 14:17:35 +08:00
Derek McGowan
30951c6f03 Add overlay symlink resolution using ReadLinkFS
Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-04 22:37:39 -07:00
Derek McGowan
21d666cfbc Update fsview to allow type registration
Move erofs implementation to plugin and register with fsview.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-04-04 22:37:38 -07:00
Maksym Pavlenko
78bcb44a34 Merge pull request #13132 from pierluigilenoci/fix/honor-stderrthreshold
Honor stderrthreshold when logtostderr is enabled
2026-04-04 16:10:11 +00:00
Sergey Kanzhelev
05d3b31586 pause image 3.10.1 -> 3.10.2 for add Windows Server 2025 (ltsc2025) support
Signed-off-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
2026-04-03 16:17:39 +00:00
Pierluigi Lenoci
2a69c0d2c8 Honor stderrthreshold when logtostderr is enabled
klog has a long-standing bug where setting -logtostderr=true causes the
-stderrthreshold flag to be silently ignored. All log messages are sent
to stderr regardless of their severity.

klog v2.140.0 introduced two new flags that allow callers to opt into the
correct behavior:

  -legacy_stderr_threshold_behavior=false
  -stderrthreshold=INFO

Set them in the CRI plugin's setGLogLevel() function, right after
klog.InitFlags() and before any other flag configuration.

Reference: kubernetes/klog#212
Signed-off-by: Pierluigi Lenoci <pierluigi.lenoci@gmail.com>
2026-04-03 10:53:54 -05:00
Gao Xiang
cb93966b9f transfer: Default to the EROFS snapshotter and differ for EROFS images
If no snapshotter is specified and `os.features` contains "erofs",
unpacking should use the EROFS snapshotter and differ.

This enhances the usability of native EROFS container images.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-04-01 13:18:23 +08:00
Aadhar Agarwal
50f5461fb7 Add dmverity support to the erofs snapshotter using veritysetup-go
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2026-03-31 20:21:39 +00:00
Maksym Pavlenko
1568602fec Merge pull request #13080 from erofs/transfer-differ-fix
transfer: fix the differ selection if differ is ""
2026-03-23 21:47:24 +00:00
Sergey Kanzhelev
27f0b12937 fix linter issues
Signed-off-by: Sergey Kanzhelev <S.Kanzhelev@live.com>
2026-03-22 22:52:10 +00:00
Gao Xiang
dc9cb1dfd5 transfer: fix the differ selection if differ is ""
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2026-03-21 15:31:09 +08:00
Sebastiaan van Stijn
22fd63994e *: modernize: stringscutprefix
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 13:36:17 +01:00
Sebastiaan van Stijn
860d97854f plugins: modernize: plusbuild
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 13:36:17 +01:00
Sebastiaan van Stijn
8fcf3a3cf1 *: modernize: rangeint
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 13:36:16 +01:00
Sebastiaan van Stijn
5ccb356620 plugins: modernize: any
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-17 13:36:11 +01:00
Derek McGowan
489b653034 Merge pull request #13022 from thaJeztah/modernize
*: modernize code
2026-03-16 22:23:04 +00:00
Samuel Karp
3e9f21c439 nri: add dependency on internal tracing plugin
Ensure that the internal tracing plugin is initialized before the
NRI plugin. This ensures that NRI has access to the global
TracerProvider when it initializes its TTRPC interceptors.

Assisted-by: gemini-cli
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-03-16 09:57:34 -07:00
Sebastiaan van Stijn
2fd5da21ed *: modernize: waitgroup
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -waitgroup -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:15 +01:00
Sebastiaan van Stijn
4b6cc97c4d plugins: modernize: any
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -any -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:15 +01:00
Sebastiaan van Stijn
cd3d63d913 *: modernize: fmtappendf
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -fmtappendf -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:14 +01:00
Sebastiaan van Stijn
b050f47efc *: modernize: testingcontext
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -testingcontext -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 18:24:03 +01:00
Sebastiaan van Stijn
b35d9ea929 plugins: modernize: rangeint
go install golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest
    modernize -rangeint -fix ./...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-15 14:56:20 +01:00
Derek McGowan
b2eeb8635e snapshotter/erofs: avoid ineffective chown on create snapshot when in block mode
In block mode, host permissions are not relevant

Signed-off-by: Derek McGowan <derek@mcg.dev>
2026-03-13 12:11:00 -07:00
Akhil Mohan
1d77b68f0e set default config_path in plugin init
move setting the config_path from default image config to plugin init.
only set the default value when both mirrors and config_path are empty,
in all other cases retain the existing behaviour

Co-authored-by: Samuel Karp <samuelkarp@google.com>
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-03-06 11:20:06 -08:00
Fu Wei
591de24057 Merge pull request #12821 from haytok/propagate-deadline-exceeded-error
fix: propagate `context deadline exceeded` error properly
2026-02-21 21:58:31 +00:00
Fabiano Fidêncio
e9622481f0 cri: propagate runtime-specific snapshotters to image service
When users configure a snapshotter in the runtime config (e.g.,
`plugins."io.containerd.cri.v1.runtime".containerd.runtimes.kata.snapshotter`),
the CRI image service was not aware of this configuration. This caused
images to be pulled with the default snapshotter instead of the
runtime-specific one, because the image service's runtimePlatforms map
was not populated with these runtime-to-snapshotter mappings.

Let's make sure that during the CRI plugin init, we iterate over all the
configured runtimes, and propagate any snapshotter configuration to the
image service.

The issue was found while working on #12835.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2026-02-20 23:05:46 +01:00
Derek McGowan
7b85f3dca6 Merge pull request #12893 from akerouanton/support-disabling-image-verifier
Don't bail out if no image verifiers available
2026-02-18 16:08:35 -08:00
Maksym Pavlenko
8ccf18724f Update sandbox API to include spec field
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-02-17 14:23:39 -08:00
Albin Kerouanton
634401d24c Don't bail out if no image verifiers available
When the local transfer plugin is instantiated, it loads verifiers
through `ic.GetByType()` which returns ErrPluginNotFound if no plugins
of the given type is available. This would happen if users explicitly
disabled the bindir plugin.

Users may wish to disable that plugin to prevent containerd from
executing arbitrary binaries on the host (e.g. when running rootless).
Currently, the only way to achieve that is to set bindir's param
`bin_dir` to the empty string but that seems more fragile than disabling
the plugin altogether.

The local transfer plugin is already checking if there are no plugins
available, and take action accordingly. Thus, not handling
`ErrPluginNotFound` seems to be an oversight.

Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
2026-02-13 09:31:39 +01:00
Hayato Kiwata
f078cebbd1 fix: propagate context deadline exceeded error properly
When a shim becomes unresponsive (e.g., stopped via SIGSTOP), ttrpc
communication times out with `context deadline exceeded`.

Currently, this error is not properly propagated, causing redundant API
calls and slow container listing by client sides.

Specifically, when executing the API to check the task state, it appears
that the `context deadline exceeded` error via ttrpc is not being handled
within `shimTask.State()` and `getProcessState()`.

As a result, when this error occurs, clients such as nerdctl cannot
recognize this error, and it is thought that the issue described below is
occurring:

- https://github.com/containerd/nerdctl/issues/4720

Therefore, this commit adds error handling to ensure timeouts are properly
handled by client sides.

Signed-off-by: Hayato Kiwata <dev@haytok.jp>
2026-01-26 22:58:28 +09:00
Maksym Pavlenko
f496ee86e4 Merge pull request #12789 from mxpv/replace
Fix go mod replace and sync with latest api changes
2026-01-23 20:45:45 +00:00
Fu Wei
10cf3c8bc6 Merge pull request #12782 from aadhar-agarwal/aadagarwal/fix-uuid
erofs-differ: use same UUID append style in tar index mode as tar conversion mode
2026-01-21 15:21:59 +00:00
jinda.ljd
cf7cb3c35e erofs: Move immutable file handling before storage.Remove
The layer blob immutable flag clearing logic was moved before
storage.Remove() call to ensure that immutable files can be properly
removed even if subsequent operations fail after storage.Remove().

The previous order had storage.Remove() called first, which meant if
any subsequent operations failed, there would be no opportunity to
remove the immutable flag on the layer blob files.

Signed-off-by: jinda.ljd <jinda.ljd@alibaba-inc.com>
2026-01-21 19:34:35 +08:00
ChengyuZhu6
f873e4d3c2 plugins/mount/erofs: use fsmount API to avoid PAGE_SIZE limit
The traditional mount() syscall has a PAGE_SIZE (typically 4KB) limit
for mount options. Use the new mount API (fsopen/fsconfig/fsmount/
move_mount) introduced in Linux 5.2 to bypass this limitation.

Fixed: #12662

Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2026-01-17 16:02:09 +08:00
Maksym Pavlenko
992597bfe9 Fix TTRPC prefix
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-01-15 13:06:50 -08:00
Aadhar Agarwal
52a92e83f0 erofs-differ: use same UUID append style in tar index mode as tar conversion mode
Use the same approach for appending UUID arguments in GenerateTarIndexAndAppendTar
as done in ConvertTarErofs for consistency between the two modes.

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2026-01-14 05:29:13 +00:00
ningmingxiao
5f0f0dcaac content: ensure root directory exists before checking fs-verity support
Currently, fs-verity support detection fails on fresh containerd
installations because the content store root directory
(io.containerd.content.v1.content) doesn't exist yet. This directory
is only created when pulling images, causing checker to
always be false on new hosts.

The IsSupported() function attempts to create a temporary directory
within rootPath to test fs-verity support, but fails when rootPath
doesn't exist, returning an error that is silently ignored.

Fix this by ensuring the root directory exists before performing
the fs-verity support check in NewLabeledStore().

Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2026-01-12 09:58:11 -06:00
Akihiro Suda
9d247a7993 Merge pull request #12433 from halaney/ahalaney/erofs-idmap-latest
Add erofs idmap support
2026-01-09 06:35:49 +00:00
Maksym Pavlenko
253fbe756a Cleanup unit tests
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2026-01-06 10:52:49 -08:00
Derek McGowan
415b5a534a Merge pull request #12567 from ChengyuZhu6/erofs-mediatype
images: add EROFS layer media type
2026-01-06 06:28:28 +00:00
Maksym Pavlenko
2bddff3f21 Merge pull request #12566 from rawahars/main
Set annotations parameter in CreateSandbox request
2026-01-05 18:45:37 +00:00
Andrew Halaney
9b50650d5c snapshots/erofs: Support idmap mounts
This disables the slow_chown feature (nobody in their right mind
is going to be choosing erofs and want to slowly chown each file),
indicates that we support idmaps if the kernel supports it, and makes
sure to chown the upperdir.

This is more or less exactly how the overlay snapshotter does things,
minus the slow_chown part (which has discussions about dropping
altogether at some point anyways).

Signed-off-by: Andrew Halaney <ahalaney@netflix.com>
2026-01-02 10:05:29 -06:00
Harsh Rawat
53e696d625 set annotations parameter in CreateSandbox request
In the CreateSandbox request, which is part of the Sandbox Controller, we ignored the `Annotations` parameter which could have been set by the caller via `WithAnnotations` option.

This commit rectifies the same and adds the Annotations parameter to the request.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
2025-12-29 17:01:14 +05:30
Gao Xiang
9a7500a974 Add support for EROFS fsmerge feature
EROFS has supported a tiny metadata-only image to reference external
blobs since Linux 5.16. This eliminates the need to mount each EROFS
layer one by one and is also useful for VM-based containers (e.g.
nerdbox and Kata containers.)

Similar to LCOW/CimFS, `snapshots.UnpackKeyPrefix` is used to
trigger fsmerge generation (typically < 100 ms) on demand in Prepare().

In the future, we can also generate fsmeta in Commit() of the final
unpacking layer (by introducing an annotation to keep the chainID).
However, in the case of intermediate layer reuse, the Prepare() handling
will still be required.

```toml
[plugins."io.containerd.snapshotter.v1.erofs"]
  max_unmerged_layers = 1      # enable fsmerge if image layers >= 2
```

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-12-29 17:39:09 +08:00
ChengyuZhu6
36f8999b94 images: add EROFS layer media type
Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2025-12-23 23:19:50 +08:00