Commit Graph

327 Commits

Author SHA1 Message Date
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
Derek McGowan
487d77ff50 Fix transfer unpack defaults on darwin
Fix the default unpack configuration on darwin to a usable
configuration.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-18 08:51:51 -08:00
Derek McGowan
497f896d65 Update default differs on darwin
Use the erofs differ by default on darwin. This could be default for all
Unix platforms but limit the default changes to fix broken cases for backports.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-18 08:51:51 -08:00
Derek McGowan
49888e001f Use default writable size in erofs snapshotter for non-Linux hosts
Non-Linux hosts are not expected to be able to directly mount erofs
snapshotters on the host system. Non-Linux hosts should use block mode
by default with a reasonably set default block size.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-18 08:51:50 -08:00
Derek McGowan
01b4c8102b Update default erofs block size on macOS during erofs diff
Use the Linux default rather than the block size from the local macOS
system. The local macOS block size is not relevant as the erofs file
will not be mounted directly on macOS.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-17 16:34:28 -08:00
Akihiro Suda
910171e90e Fix directory permissions
- Create /var/lib/containerd with 0o700 (was: 0o711).
- Create config.TempDir with 0o700 (was: 0o711).
- Create /run/containerd/io.containerd.grpc.v1.cri with 0o700 (was: 0o755).
- Create /run/containerd/io.containerd.sandbox.controller.v1.shim with 0o700 (was: 0o711).
- Leave /run/containerd and /run/containerd/io.containerd.runtime.v2.task created with 0o711,
  as required by userns-remapped containers.
  /run/containerd/io.containerd.runtime.v2.task/<NS>/<ID> is created with:
  - 0o700 for non-userns-remapped containers
  - 0o710 for userns-remapped containers with the remapped root group as the owner group.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-11-04 16:04:30 +09:00
Gao Xiang
7bf5b92e6e Add Readonly setup to EROFS mount loop handler
See __fsverity_file_open():

``` c
int __fsverity_file_open(struct inode *inode, struct file *filp)
{
	if (filp->f_mode & FMODE_WRITE)
		return -EPERM;
	return ensure_verity_info(inode);
}
```

Fixes: 5b9d871fea ("Add EROFS mount handler plugin")
Closes: https://github.com/containerd/containerd/issues/12451
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-11-02 08:35:52 +08:00
Wei Fu
ba524db349 snapshot: check parent's kind before commit
We should reject commit request if target parent is not committed.
Just in case we rebase active snapshot on active one.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2025-10-31 11:09:11 -04:00
Maksym Pavlenko
c07f9220cb Merge pull request #12409 from henry118/followup-12332
Remove rebase validation logic from overlay snapshotter
2025-10-27 18:42:10 +00:00
Henry Wang
d939b6af5f Remove rebase validation logic from overlay snapshotter
Signed-off-by: Henry Wang <henwang@amazon.com>
2025-10-24 21:56:59 +00:00
Derek McGowan
7b7c5c1711 Add rebase capability to erofs
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-24 14:06:56 -07:00
Henry Wang
0198b87fcf Implement parallel unpack
Signed-off-by: Henry Wang <henwang@amazon.com>
2025-10-24 17:54:26 +00:00
Derek McGowan
9a43ee660a Merge pull request #6488 from evankanderson/main
Default config_path if legacy registry options are not set.
2025-10-24 01:28:00 +00:00
Gao Xiang
5b9d871fea Add EROFS mount handler plugin
Commit ee8ae9d569 ("Update erofs snapshotter to use mount manager")
temporarily removed the file-backed mount feature to adapt to the new
mount manager infrastructure as a quick start.

After the mount manager was introduced, a specific mount type can be
handled with a mount handler plugin to provide a dedicated mount
process (e.g. setup loopback devices in advance or calling external
mount helpers).

This commit adds a default EROFS mount handler for the Linux hosts
to set up loop devices for mount sources and "device=" external file
blobs if necessary (i.e. when file-backed mounts are unavailable),
allowing common runtimes such as runC to work directly, e.g.
 ``` sh
 mount -t erofs /var/lib/containerd/io.containerd.snapshotter.v1.erofs/snapshots/1/layer.erofs \
  /run/containerd/io.containerd.mount-manager.v1.bolt/t/346/1
 ```
 will be handled as
 ``` sh
 mount -t erofs /dev/loop1 /run/containerd/io.containerd.mount-manager.v1.bolt/t/346/1
 ```
and
 ``` sh
 mount -t erofs /var/lib/containerd/io.containerd.snapshotter.v1.erofs/snapshots/7/fsmeta.erofs \
   -odevice=/var/lib/containerd/io.containerd.snapshotter.v1.erofs/snapshots/1/layer.erofs,\
     device=/var/lib/containerd/io.containerd.snapshotter.v1.erofs/snapshots/2/layer.erofs,\
     ...
     device=/var/lib/containerd/io.containerd.snapshotter.v1.erofs/snapshots/7/layer.erofs
   /run/containerd/io.containerd.mount-manager.v1.bolt/t/335/1
 ```
 will be handled as
 ``` sh
 mount -t erofs /dev/loop1 -odevice=/dev/loop2,device=/dev/loop3,... \
   /run/containerd/io.containerd.mount-manager.v1.bolt/t/335/1
 ```
if file-backed mounts are unavailable.

For other host platforms (e.g. Darwin hosts) or specific runtimes
that require EROFS raw mounts instead of parsed mounts, this plugin
can be explicitly masked off by users.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-10-22 22:57:42 +08:00
Gao Xiang
8a6e6263f8 Support arbitary mkfs size (not only in MiB)
Rename `default_size_mb` to `default_size` so that it's similar to
Docker's `--storage-opt size=30G` flag.  For example,

``` toml
[plugins."io.containerd.snapshotter.v1.erofs"]
  default_size = "5GB"
```

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-10-21 15:35:05 +08:00
Fu Wei
e95415b723 Merge pull request #12333 from dmcgowan/erofs-block-files
Update erofs snapshotter to use mount manager
2025-10-20 02:43:50 +00:00
Evan Anderson
5386802f8a Default config_path if legacy registry options are not set.
Signed-off-by: Evan Anderson <evan.k.anderson@gmail.com>
2025-10-16 17:51:44 -07:00
Derek McGowan
2f75989e2a Update erofs to use mount transformers
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-14 22:53:43 -07:00
Derek McGowan
be9f183f45 Add mount transformers to mount manager
Extend the mount manager to support more transformers than format. The
transformers allow altering the mount before it is passed to the mount
handlers. These could be one-time actions which are needed to perform
the mount.

Adds mkdir and mkfs actions which can be used to prepare the arguments
for a mount. The actions can be limited to actions within the target
mount directory or plugin directories.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-14 16:35:53 -07:00
Derek McGowan
1adaf27c1e Update erofs to compile on Darwin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-13 19:33:44 -07:00
Derek McGowan
ee8ae9d569 Update erofs snapshotter to use mount manager
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-13 19:33:44 -07:00