Commit Graph

1919 Commits

Author SHA1 Message Date
Derek McGowan
cc2a52ca8f Update pkg/oci to use FS interface
Switch to use fs.FS interface over directly requiring path string.
Use os.OpenRoot over continuity RootPath.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-08-29 12:59:35 -07:00
Mike Brown
9aebe599ec Merge pull request #12217 from klihub/devel/main/update-nri
nri: update NRI to v0.10.0.
2025-08-22 17:37:09 +00:00
Krisztian Litkey
b7a401f1d2 cri: warn about deprecated v0.1.0-style NRI plugins.
Co-authored-by: Chris Henzie <chrishenzie@google.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2025-08-21 21:37:56 +03:00
Maksym Pavlenko
a5390cda20 Merge pull request #11966 from zouyee/master
fix: preserve nsPath on mount failure to ensure cleanup
2025-08-20 03:02:28 +00:00
Maksym Pavlenko
c5372ac8b1 Merge pull request #11942 from thaJeztah/oci_test_WithParentCgroupDevices
pkg/oci: add basic test for WithParentCgroupDevices
2025-08-18 20:51:21 +00:00
Wei Fu
6ce7f6d87a pkg/sys: check SupportsPidFD first
Checking this earlier and bailing is preferable to checking this to after we
try to StartProcess.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2025-08-12 14:53:29 -04:00
Jose Fernandez
45e02e1dc1 sys: fix pidfd leak in UnshareAfterEnterUserns
UnshareAfterEnterUserns() creates a pidfd via os.StartProcess() with
CLONE_PIDFD but fails to close the file descriptor in any code path,
resulting in a file descriptor leak for every container that uses user
namespace isolation.

The leak occurs because:
- The pidfd is created when PidFD field is set in SysProcAttr
- The original defer block only calls PidfdSendSignal() and
  pidfdWaitid()
- No code path calls unix.Close(pidfd) to release the file descriptor

This causes one pidfd leak per container launch when user namespace
isolation is enabled (e.g., Kubernetes pods with hostUsers: false). In
production environments with high container churn, this can exhaust the
system's file descriptor limit.

Fix the leak by adding a defer statement immediately after process
creation that ensures unix.Close(pidfd) is always called, regardless of
which code path is taken. This guarantees cleanup even if the function
returns early due to errors or lack of pidfd support.

This follows the same cleanup pattern already established in
core/mount/mount_idmapped_utils_linux.go:getUsernsFD() which properly
closes its pidfd.

Closes: #12166
Signed-off-by: Jose Fernandez <josef@netflix.com>
2025-08-06 20:26:48 -06:00
Fu Wei
87742bd35f Merge pull request #11857 from djdongjin/remove-go-version-specific-code
chore: remove go version specific code
2025-07-06 19:02:31 +00:00
yashsingh74
03a44a2d7c fix: Used nolint to ignore the static checks
Signed-off-by: yashsingh74 <yashsingh1774@gmail.com>
2025-06-18 14:16:41 +05:30
yashsingh74
403f86ecc2 fix: QF1012: Use of fmt.Fprintln(...)
Signed-off-by: yashsingh74 <yashsingh1774@gmail.com>
2025-06-18 14:16:41 +05:30
yashsingh74
d93d18c857 fix: QF1001: could apply De Morgan's law (staticcheck)
Signed-off-by: yashsingh74 <yashsingh1774@gmail.com>
2025-06-18 14:16:41 +05:30
Jin Dong
734d52c39c chore: remove specific go version code
Now that we have 1.24.x as go min version, I think
we can remove this go code specific to a lower
version.

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2025-06-12 21:35:09 -04:00
zouyee
04ce9f884d feat: preserve nsPath on mount failure to ensure cleanup
Signed-off-by: zouyee <zouyee1989@gmail.com>
2025-06-12 14:59:10 +08:00
Mike Brown
4bcd549f74 Merge pull request #11946 from thaJeztah/oci_privileged_no_var
pkg/oci: don't use var for WithPrivileged
2025-06-09 02:00:28 +00:00
Akihiro Suda
cd0f2cc23a Merge pull request #11945 from thaJeztah/oci_no_vars_for_funcs
pkg/oci: don't use vars for WithAllKnownCapabilities, WithAllCurrentCapabilities
2025-06-08 06:19:37 +00:00
Maksym Pavlenko
a6c250ed77 Merge pull request #11938 from thaJeztah/oci_linting
pkg/oci: fix minor linting issues
2025-06-06 22:21:33 +00:00
Phil Estes
0bf07cd5c6 Merge pull request #11939 from thaJeztah/oci_rm_go116
pkg/oci: remove compatibility code for go1.16 and older
2025-06-04 15:02:30 +00:00
Sebastiaan van Stijn
8de612020e pkg/oci: don't use var for WithPrivileged
This variable was introduced in 062c3a00ef,
which didn't describe it as intentional to be able to override the option.

Based on the above, I assume the use of a variable was purely convenience,
the there's no intent for packages to be able to override them, so this
patch changes these to be a regular function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 16:35:13 +02:00
Sebastiaan van Stijn
cf667aa7ee pkg/oci: add basic test for WithParentCgroupDevices
It was not used in the code, and had no coverage, so adding some
basic unit-tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 16:19:00 +02:00
Sebastiaan van Stijn
d72c21450f pkg/oci: don't use vars for WithAllKnownCapabilities, WithAllCurrentCapabilities
These were introduced in c818a6b13d, refactored
in 808b223536 and bdd84abf05,
and moved in a2d1a8a865, but none provided
a motivation for using a variable / alias for these.

Based on the above, I assume the use of a variable was purely convenience,
the there's no intent for packages to be able to override them, so this
patch changes these to be a regular function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 16:10:41 +02:00
Sebastiaan van Stijn
ac3c3ad5da pkg/oci: cleanup some tests
- Use testify for asserting
- Fix various unhandled errors
- Use native t.TempDir() for temporary files

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 13:42:09 +02:00
Sebastiaan van Stijn
4de598d94b pkg/oci: remove compatibility code for go1.16 and older
These were added as part of b7f673790f,
to provide backward compatibility with go1.16, which we no longer
supports, so we can remove this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 12:52:40 +02:00
Sebastiaan van Stijn
17c632e785 pkg/oci: fix minor linting issues
- remove redundant aliases for imports
- rename variables that shadowed imports
- use errors.Is instead of straight error comparing

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 12:45:57 +02:00
Derek McGowan
aa9c17c692 Add symlink breakout test for overriden path
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-20 16:58:12 -07:00
Akihiro Suda
f209a82ca9 Merge pull request #11860 from thaJeztah/oci_no_panic
pkg/oci: prevent panic for some platform-specific options
2025-05-20 16:53:38 +00:00
Sebastiaan van Stijn
b0052d94a6 pkg/oci: prevent panic for some platform-specific options
Some of these options are designed to be a no-op when used on a Spec
that doesn't match the platform for the option. However, if the given
plaform was not present, they would panic.

This patch:

- Adds an early-return for options that are only applied on a
  specific platform.
- Update the GoDoc for these functions to describe they're a
  no-op on other platforms.
- Adds some rudimentary unit-tests to verify their behavior.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 00:44:45 +02:00
Samuel Karp
38c9bb93a3 Revert "perf(applyNaive): avoid walking the tree for each file in the same directory"
This reverts commit d8063c30dd.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2025-05-12 16:36:10 -07:00
Derek McGowan
7360c739fc Fix image inspect skip over missing content
Rather than exiting early with an error, just output that the content
does not exist locally and continue. This is helpful for displaying
multiplatform images when the content for every platform was not pulled.
If a platform that did not exist locally showed up before one that did,
the inspect would error out before even showing the content.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-05 16:13:39 -07:00
Derek McGowan
ae9b003d24 Merge pull request #10762 from mxpv/dbg
Enable HTTP debug and trace for transfer based puller
2025-04-24 16:22:02 +00:00
Maksym Pavlenko
17b6e1ef85 Allow streaming to client
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 18:03:29 -07:00
Maksym Pavlenko
bd8e6c727d Enable http debug and tracing for non local puller
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 17:39:57 -07:00
Maksym Pavlenko
27e6c117d9 Move HTTP debug code to pkg
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2025-04-23 17:38:47 -07:00
Sebastiaan van Stijn
1477874494 use lazyregexp to compile regexes on first use
- internal/cri/bandwidth: use lazyregexp to compile regexes on first use
- pkg/identifiers: use lazyregexp to compile regexes on first use
- pkg/progress: use lazyregexp to compile regexes on first use
- pkg/reference: use lazyregexp to compile regexes on first use
- pkg/sys: use lazyregexp to compile regexes on first use

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-22 20:29:14 +02:00
Phil Estes
250593568f Merge pull request #11684 from AkihiroSuda/postpone-deprecation-2.1
config: postpone planned v2.1 deprecations to v2.2
2025-04-17 02:02:48 +00:00
Akihiro Suda
764dcf77a8 config: postpone planned v2.1 deprecations to v2.2
We going to release v2.1 earlier than we have once expected at that time,
so extend the grace period for migration.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-17 09:14:15 +09:00
Akihiro Suda
499238a52a Remove deprecated dynamic library plugins
Dynamic library plugins have been deprecated since v2.0 (PR 9238)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-17 09:12:46 +09:00
Akihiro Suda
d9c889568e Remove the support for Schema 1 images
Schema 1 (`application/vnd.docker.distribution.manifest.v1+prettyjws`) has been
officially deprecated since containerd v1.7 (PR 6884), and disabled since v2.0 (PR 9765).

Users who have been seeing warnings like `conversion from schema 1 images is deprecated`
now have to rebuild the image with Schema 2 or OCI.

Schema 2 was introduced in Docker 1.10 (Feb 2016), so most users should have been already
using Schema 2 or OCI.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-11 09:03:26 +09:00
QiPing Wan
be9ca11a14 fix call fmt.Errorf with wrong error
Signed-off-by: QiPing Wan <alingse@foxmail.com>
2025-04-08 09:09:40 +08:00
ningmingxiao
1dbb7f2ae3 pkg/sys: improve GetLocalListener/CreateUnixSocket error message
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2025-04-01 12:53:41 +08:00
Jin Dong
42effa3b91 Mark NetworkPluginBinDir as DEPRECATED
To make it as DEPRECATED, this PR does the following:

1. Changes config default to use `NetworkPluginBinDirs`;
2. Mark `NetworkPluginBinDir` as deprecated (in config version 3);
3. Add config migration from 2 to 3, which migrates `bin_dir`
  in version 2 to `bin_dirs` in version 3.

Signed-off-by: Jin Dong <djdongjin95@gmail.com>

[wip] add deprecation warning

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2025-03-21 16:59:32 +00:00
Jin Dong
c8effff1a8 Fix CI lint error
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2025-03-18 01:16:07 +00:00
Derek McGowan
b430e5ac3a Merge commit from fork
validate uid/gid
2025-03-18 01:23:21 +08:00
Craig Ingram
de1341c201 validate uid/gid 2025-03-11 14:44:38 +00:00
Phil Estes
b1924f1fd2 Merge pull request #11337 from azr/tar-rootpath-cache
perf(applyNaive): avoid walking the tree for each file in the same directory
2025-03-07 21:08:05 +00:00
Adrien Delorme
d8063c30dd perf(applyNaive): avoid walking the tree for each file in the same directory
This for example allowed us to gain ~5s while pulling ghcr.io/huggingface/text-generation-inference:3.0.2

Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
Co-Authored-By: Corentin REGAL <143578+co42@users.noreply.github.com>
2025-02-28 18:50:45 +01:00
Akihiro Suda
2841fc8107 Merge pull request #11433 from zhaodiaoer/main
pkg: prevent oom watcher from depending on shim pkg
2025-02-26 01:02:05 +00:00
Samuel Karp
9c2eb67756 Merge pull request #11435 from chrishenzie/ignore-zombies
Ignore defunct verifier procs in test
2025-02-25 22:42:23 +00:00
Chris Henzie
76858ac8e3 Ignore defunct verifier procs in test
This test produces zombies when PID 1 does not properly reap child
processes. Modifies the test to ignore these processes in the meantime.

Signed-off-by: Chris Henzie <chrishenzie@google.com>
2025-02-25 13:29:49 -08:00
Lei Liu
268880bf53 [improve] prevent oom watcher depend on shim pkg.
Signed-off-by: Lei Liu <liulei.pt@bytedance.com>
2025-02-25 22:06:15 +08:00
Kirtana Ashok
6c02321f6e Merge pull request #11179 from ambarve/blocked_cim
Support for importing layers in the block CIM format.
2025-02-24 22:21:10 +00:00