Commit Graph

395 Commits

Author SHA1 Message Date
Maksym Pavlenko
1e3446f24b Merge pull request #12666 from aadhar-agarwal/aadagarwal/fix-st1005
Fix ST1005 lint violations: lowercase error strings
2026-01-07 01:06:39 +00:00
Aadhar Agarwal
d6ee6f69b2 Fix ST1005 lint violations: lowercase error strings
Error strings should not be capitalized (unless beginning with proper
nouns or acronyms) or end with punctuation, per Go style guide and
staticcheck ST1005.

This change lowercases the first letter of error messages in fmt.Errorf
calls throughout the codebase, while preserving uppercase for acronyms
at the start of error strings (e.g., NRI, RDT, CDI, UID, GID, VHD, FUSE).

Also fixes typo 'faild' -> 'failed' in resolver_test.go.

Changes:
- core/metadata: target.Digest, target.Size, target.MediaType
- core/remotes/docker: fetcher.Seek, fetcherByDigest
- integration: various test error messages
- internal/cri/server: containerConfig
- plugins/snapshots: erofs

Fixes #12011

Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
2026-01-07 00:26:28 +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
ChengyuZhu6
36f8999b94 images: add EROFS layer media type
Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2025-12-23 23:19:50 +08:00
Kal
5b184601d3 Fix typo in README.md for shim author section
Signed-off-by: Kal <119035751+Kaleab-Ayenew@users.noreply.github.com>
2025-12-16 15:20:25 +03:00
ningmingxiao
508f8cac6d add some log if blob is skipped to download
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2025-12-08 11:11:52 +08:00
Sebastiaan van Stijn
459a95287b core/runtime/v2: remove uses of otelgrpc.UnaryClientInterceptor
The otelgrpc.UnaryClientInterceptor and otelgrpc.StreamClientInterceptor
options were deprecated and removed in favor of NewClientHandler.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-01 14:32:11 +01:00
Akihiro Suda
f37f951f56 Merge pull request #12545 from erofs/fixes
Avoid using redundant loop devices to run mkfs for mount manager tests.
2025-11-28 07:13:24 +00:00
Wei Fu
a5c84021c8 core/mount: should not call removeLoop when set autoclear
In CI we run make root-test via gotestsum, which executes multiple
package tests concurrently. TestAutoclearTrueLoop attempts to invoke
LOOP_CLR_FD using a device name, which introduces a race condition.

Example race:

Process P1 represents mount.test which runs TestAutoclearTrueLoop
Process P2 represents manager.test which runs TestLoopbackMount

T1: P1 closes fd of loop-device (loop3) (kernel unsets backing-file on close)
T2: P2 gets loop3 from /dev/loop-control
T3: P2 configures loop3 with backing file successfully
T4: P1 invokes removeLoop to clear backing file for loop3

You might see that failure like this

```
=== FAIL: core/mount/manager TestLoopbackMount (0.05s)
    log_hook.go:47: time="2025-10-23T21:49:22.532811960Z" level=debug msg="activating mount" func="manager.(*mountManager).Activate" file="/home/runner/work/containerd/containerd/core/mount/manager/manager.go:134" mounts="[{loop /tmp/TestLoopbackMount989607109/001/fs-1621892597  []} {format/ext4 {{ mount 0 }}  []}]" name=id1 testcase=TestLoopbackMount
    helpers.go💯 unmount /tmp/TestLoopbackMount989607109/001/test-mount-3030342351
    manager_linux_test.go:80:
        	Error Trace:	/home/runner/work/containerd/containerd/core/mount/manager/manager_linux_test.go:80
        	            				/home/runner/work/containerd/containerd/core/mount/manager/manager_linux_test.go:105
        	Error:      	Received unexpected error:
        	            	failed to get loop device info: no such device or address
        	Test:       	TestLoopbackMount
```

To fix this, the test now compares backing-file's inode directly and does
not call removeLoop when autoclear is set.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2025-11-23 21:31:08 -05:00
Gao Xiang
190ed6b677 Avoid using redundant loop devices to run mkfs for mount manager tests.
mkfs.ext4 supports creating filesystems from regular files.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-11-19 11:50:01 +08:00
Brian Goff
3c9a0bd316 Revert "Implement io.ReaderAt on docker fetch reader"
This reverts commit 4bf1705a88.

This caused issues for downstream clients who were wrapping the type
contingent on it implementing io.ReaderAt.
Consequently this is causing headaches due to increased round trips with
the remote.

Meanwhile I only added this as a convenience for implementing
content.Provider in the remote which can done even without the original
change, just... less conveniently.

In hindsight, this was just a bad change as it has a rather wide impact
and the actual implementation isn't an optimized ReaderAt.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2025-11-17 15:55:42 -08:00
Tonis Tiigi
720db28741 remotes: fix possible panic from WithMediaTypeKeyPrefix
As the same instance of a map is used in context and mutated
directly, this leads to a  situation where:
- Calling WithMediaTypeKeyPrefix from parallel goroutines where
  the context was based on the same base context can trigger a panic.
- A subcontext calling WithMediaTypeKeyPrefix changes the value for
  another context when they both originate from the same base context.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-11 22:19:08 -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
Derek McGowan
8bcea1029a Merge pull request #12458 from dmcgowan/fix-referrers-manifest-size
Add size check to referrers response
2025-11-03 23:39:04 +00:00
Derek McGowan
565151652e Add size check to referrers response
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-11-03 12:10:54 -08:00
Fu Wei
746f6af1f9 Merge pull request #12447 from fuweid/check-parent-kind-before-commit
snapshot: check parent's kind before commit
2025-10-31 17:35:40 +00: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
Akihiro Suda
2e0e47c472 Deprecate cgroup v1
For issue 12443

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-10-31 19:34:16 +09:00
Derek McGowan
d9d3c82237 Cleanup load shim info
Avoid unnecessary new configuration and instead cache the info result
when first used.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-29 13:04:18 -07:00
Derek McGowan
ec37347d85 Merge pull request #12435 from dmcgowan/referrers-interface
Update referrers interface to support more options
2025-10-29 12:56:29 -07:00
Derek McGowan
42336c7de6 Update referrers interface to support more options
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-28 22:37:05 -07:00
Tonis Tiigi
9840ad93e1 docker: fix addQuery with multiple calls
In previous implementation every call would
replace the whole query instead of adding to it.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-28 18:25:00 -07:00
Henry Wang
0198b87fcf Implement parallel unpack
Signed-off-by: Henry Wang <henwang@amazon.com>
2025-10-24 17:54:26 +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
Derek McGowan
995d9718a8 Merge pull request #12311 from tonistiigi/referrers-support
client: add referrers support to client
2025-10-21 22:12:39 +00: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
Gao Xiang
3cc411c8b2 Fix backreference support for mount manager
The mount manager GC seems to be broken on my local setup.

According to commit df87a8f71b ("Add support for backreferences
in gc"), the interface name should be "ActiveWithBackRefs" instead.

After this patch, erofs and ext4 mounts won't be GCed in advance.

Fixes: 184fae60fc ("Add backreference support to mount manager")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2025-10-21 15:06:20 +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
Derek McGowan
0d62c71885 Update loopback test to make initialization more robust
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-19 13:38:40 -07:00
Tonis Tiigi
a7d26b35ec client: add referrers support to client
Allows management of referrer objects when performing
pull, archive export and archive import.

Referrer objects are linked to their subjects via GC
labels. The label is based on sha256 checksum of the
object instead of incremental numbers as referrers are
not immutable and don't have any strict order.

In OCI-layout referrers that are not already in the exported
tree are added to the main index.json with
io.containerd.manifest.subject annotation.

On import such descriptors with that annotation
do not create digest-based images in the image store.

Note that this does not mean all the referrer objects in
the registry are now pulled/exported/imported by default.
The caller of the client pkg functions can choose which
referrer objects should also be handled.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 13:43:36 -07:00
Mike Brown
79f7818b13 Merge pull request #12142 from ningmingxiao/fix_load_task
restart: use goroutine to speedup loadShims
2025-10-17 14:28:04 +00:00
Derek McGowan
25c3871baa Switch mount manager tests to ext4
Reduce the size of the test files. Even using sparse files, the reported
large size may cause issues in some test environments.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-16 16:58:37 -07:00
Derek McGowan
55d5d5b500 Add Close method to mount manager
Adding a close method allows the mount manager to close any open file
descriptors. The method will also be called automatically by containerd
on shutdown.

Ensure the tests call Close to avoid leaking file descriptors or errors
on Windows cleaning up directories that are in use.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-16 16:01:29 -07:00
Derek McGowan
1684c4f46d Merge pull request #9371 from makkes/lenient-digest-hdr
Make dockerPusher more compliant with distribution spec
2025-10-16 16:43:30 +00:00
Derek McGowan
92bc4fadc8 Update task manager to use mount transformers
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-14 22:53:43 -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
ningmingxiao
932b65a492 restart:use goroutine to speedup loadShims
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2025-10-09 09:48:09 +08:00
Derek McGowan
36c22f45c8 Update referrers fallback logic to always have a fallback
Always attempt the fallback on hosts configured with the referrers
capability. Fallback for any non-404 error.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-07 15:38:26 -07:00
Fu Wei
61ddcd5372 Merge pull request #12063 from dmcgowan/mount-manager
Add mount manager
2025-10-03 14:01:38 +00:00
Derek McGowan
c7b3114ebb Update mount manager code documentation
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-30 13:37:11 -07:00
Derek McGowan
f3af360f6d Update runtime to read allowed custom mounts from runtime
Let the runtime specify which custom mounts it will support

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-30 13:37:11 -07:00
Derek McGowan
94e6bcea50 Add support for allowing custom types through mount manager
Allow the mount manager to skip handling of custom types. Ensure that
custom types are still working with formatted mounts.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:38 -07:00
Derek McGowan
efc9950114 Add runtimes option to task manager
Allow task manager to fetch info on runtimes at startup.
Use this info to configure whether the runtime allows formatted mounts.
This info could also be used in the future to enforce policy such as
requiring a pre-known set of runtimes or specific runtime properties.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:38 -07:00
Derek McGowan
dd9c43150a Add option to allow formatted mounts
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:38 -07:00
Derek McGowan
9c21e867ed Handle flaky case for loop autoclear
The autoclear may take a bit of time to clear out the file, check
multiple times for the file to get removed before returning an error.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:37 -07:00
Derek McGowan
f7b77e649c Update mount manager cleanup logic
Avoid keeping file descriptor open to directory which is getting
removed. Update error handling and wrapping to provide more clarity
around failures.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:37 -07:00
Derek McGowan
93070961b7 Update snapshotter tests to use mount manager
Create separate package for snapshotter test in metadata package to
prevent circular dependency.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:36 -07:00
Derek McGowan
fa327566bb Fix mount manager deactivate errors
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:36 -07:00