Commit Graph

653 Commits

Author SHA1 Message Date
Fu Wei
dc7dba9c20
Merge pull request #9239 from jiangliu/cri-multi-snapshotters
CRI: use (snapshotter_id, snapshot_key) to uniquely identify snapshots
2023-10-18 09:30:55 +08:00
Jiang Liu
8e7c10c6d0 CRI: enhance ImageFsInfo() to support multiple snapshotters
Enhance cri/server/image/imagefs_info.go:ImageFsInfo() to support
snapshotter per runtime. Now `ImageFsInfoResponse.ImageFilesystems` may
contain multiple entries.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-10-17 17:38:18 +08:00
Jiang Liu
5ad6f34329 CRI: use (snapshotter_id, snapshot_key) to uniquely identify snapshots
Before snapshotter per runtime, CRI only supports a global snapshotter.
So a snapshot can be uniquely identified by `snapshot_key`. With snapshotter
per runtime enabled, there may be multiple snapshotters used by CRI. So only
(snapshotter_id, snapshot_key) can uniquely identify a snapshot.
Also extends CRI/store/snapshot/Store to support multiple snapshotters.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
2023-10-16 10:21:10 +08:00
Derek McGowan
7b2a918213
Generalize the plugin package
Remove containerd specific parts of the plugin package to prepare its
move out of the main repository. Separate the plugin registration
singleton into a separate package.

Separating out the plugin package and registration makes it easier to
implement external plugins without creating a dependency loop.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-12 21:22:32 -07:00
Derek McGowan
a80606bc2d
Move plugin type definitions to containerd plugins package
The plugins packages defines the plugins used by containerd.
Move all the types and properties to this package.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-12 20:52:56 -07:00
Maksym Pavlenko
1b31993240 Rename sbserver to server
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 15:46:57 -07:00
Maksym Pavlenko
fa1d3a9ccb Fix dependencies after remove
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 10:30:46 -07:00
Maksym Pavlenko
536abf1b35 Remove legacy CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:18:45 -07:00
Maksym Pavlenko
33b1a833c6 Move CRI testing package out
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:18:20 -07:00
Maksym Pavlenko
016114ff6f Move bandwidth package out of CRI server
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 09:12:52 -07:00
Samuel Karp
841c693710
Merge pull request #9076 from CFSworks/fix-ipv6-pref
Fix `ip_pref` configuration option
2023-10-06 23:31:45 -07:00
Fu Wei
bce8fe60df
Merge pull request #9183 from dcantah/cri-snapshotter-platform 2023-10-04 11:40:33 +08:00
Kohei Tokunaga
6169433b6b
Fix linter issues for golangci-lint 1.54.2
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-10-03 21:56:47 +09:00
Danny Canter
e3cb7471a6 CRI: Snapshotter per runtime handler adjustments
Pass the passed in context into some nested function calls, wrap
errors instead of %+v, and change some tests to strictly just test
for an error and not an exact error.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-10-03 02:05:34 -07:00
Fu Wei
1f0caa11c7
Merge pull request #9158 from AkihiroSuda/reword-cri-disable_cgroup 2023-09-30 01:22:56 +08:00
Akihiro Suda
8ffb03d689
cri: stop recommending disable_cgroup
Disabling cgroup is no longer needed since cgroup v2

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-29 23:08:00 +09:00
Akihiro Suda
5365f4b29e
cri: call RegisterReadiness after NewCRIService
`NewCRIService()` may easily fail and its error has to be ignored
unless the CRI plugin is in the `required_plugins` list.

Now this has to be called before `RegisterReadiness()`, as
PR 9153 "Require plugins to succeed after registering readiness"
was merged on 2023-09-29.

Fix issue 9163: `[Regression in main (2023-09-29)]: containerd-rootless.sh doesn't start up`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-29 23:06:36 +09:00
Akihiro Suda
9ffb34ac49
Merge pull request #9054 from macOScontainers/canonicalize-filter-mount-path
Fix usages of `mountinfo.PrefixFilter`
2023-09-27 05:10:27 +09:00
Derek McGowan
b5615caf11
Update go-toml to v2
Updates host file parsing to use new v2 method rather than the removed
toml.Tree.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-22 15:35:12 -07:00
Derek McGowan
e0e6f870b7
Merge pull request #9086 from dmcgowan/move-to-log-repo
Use github.com/containerd/log
2023-09-22 09:25:29 -07:00
Derek McGowan
508aa3a1ef
Move to use github.com/containerd/log
Add github.com/containerd/log to go.mod

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-22 07:53:23 -07:00
Fu Wei
7a0e6b7e77
Merge pull request #9112 from adityaramani/handle-shim-kill
Sandbox: Handle unexpected shim kill events
2023-09-22 13:31:11 +08:00
Derek McGowan
9e819fb4a8
Update CRI image store to not use containerd client
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-20 10:11:51 -07:00
Aditya Ramani
729c97cf39 Handle unexpected shim kill events
When a shim process is unexpectedly killed in a way that was not initiated through containerd - containerd reports the pod as not ready but the containers as running. This results in kubelet repeatedly sending container kill requests that fail since containerd cannot connect to the shim.

Changes:

- In the container exit handler, treat `err: Unavailable` as if the container has already exited out
- When attempting to get a connection to the shim, if the controller isn't available assume that the shim has been killed (needs to be done since we have a separate exit handler that cleans up the reference to the shim controller - before kubelet has the chance to call StopPodSandbox)

Signed-off-by: Aditya Ramani <a_ramani@apple.com>
2023-09-18 12:15:55 -07:00
Rodrigo Campos
a81f80884b Revert "cri: Throw an error if idmap mounts is requested"
This reverts commit 7e6ab84884.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-09-13 16:44:54 +02:00
Rodrigo Campos
ab5b43fe80 cri/sbserver: Pass down UID/GID mappings to OCI runtime
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-09-13 16:44:54 +02:00
Rodrigo Campos
e0b2b17de3 cri/server: Add tests for the linux-specific parts of VolumeMounts()
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-09-13 16:42:31 +02:00
Rodrigo Campos
10cb112e4a cri/server: Add tests for ContainerMounts()
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-09-13 16:42:31 +02:00
Rodrigo Campos
97dfa7f556 cri/server: Pass down uidMappings to OCI runtime
When the kubelet sends the uid/gid mappings for a mount, just pass them
down to the OCI runtime.

OCI runtimes support this since runc 1.2 and crun 1.8.1.

And whenever we add mounts (container mounts or image spec volumes) and
userns are requested by the kubelet, we use those mappings in the mounts
so the mounts are idmapped correctly. If no userns is used, we don't
send any mappings which just keeps the current behavior.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-09-13 16:42:31 +02:00
Marat Radchenko
d94a789d15 Fix usages of mountinfo.PrefixFilter
It says: The prefix path **must be absolute, have all symlinks resolved, and cleaned**. But those requirements are violated in lots of places.

What happens when it is given a non-canonicalized path is that `mountinfo.GetMounts` will not find mounts.

The trivial case is:
```
$ mkdir a && ln -s a b && mkdir b/c b/d && mount --bind b/c b/d && cat /proc/mounts | grep -- '[ab]/d'
/dev/sdd3 /home/user/a/d ext4 rw,noatime,discard 0 0
```
We asked to bind-mount b/c to b/d, but ended up with mount in a/d.
So, mount table always contains canonicalized mount points, and it is an error to look for non-canonicalized paths in it.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-09-10 15:14:26 +03:00
Sam Edwards
f77185f9e8 Fix "even if IPv4 comes first" test to have IPv4 first
Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2023-09-08 21:46:10 -06:00
Sam Edwards
88a849626f Don't use To16() != nil to detect IPv6 addresses
The ip.To16() function returns non-nil if `ip` is any kind
of IP address, including IPv4. To look for IPv6 specifically,
use ip.To4() == nil.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2023-09-08 21:44:49 -06:00
Derek McGowan
b11439fc4b
Merge pull request #9034 from thaJeztah/replace_reference
replace reference/docker for github.com/distribution/reference v0.5.0
2023-09-05 06:52:29 -07:00
Akihiro Suda
e30a40eb65
Merge pull request #9016 from djdongjin/remove-most-logrus
Remove most logrus import
2023-09-05 16:09:12 +09:00
Fu Wei
e2bf34feaf
Merge pull request #9033 from dcantah/sberror-include-id
CRI: Include sandbox ID in failed to recover error
2023-09-02 10:48:34 +08:00
Sebastiaan van Stijn
7d0ab4fc2c
remove uses of github.com/runc/libcontainer/cgroups
runc considers libcontainer to be "unstable" (not for external use),
so we try not to use it. Commit ed47d6ba76
brought back the dependency on other parts of libcontainer, but looks to
be only depending on a single utility, which in itself was borrowed from
github.com/coreos/go-systemd to not introduce CGO code in the same package.

This patch copies the version from github.com/coreos/go-systemd (adding
proper attribution, although the function is pretty trivial).

runc is in process of moving the libcontainer/user package to an external
module, which means we can remove the dependency on libcontainer entirely
in the near future. There is one more use of `libcontainer` in our vendor
tree; it looks like CDI is depending on one utility (devices.DeviceFromPath);
a943033a8b/vendor/github.com/container-orchestrated-devices/container-device-interface/pkg/cdi/container-edits_unix.go (L38)

We should remove the dependency on that utility, and add a CI check to
prevent bringing it back.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-01 12:10:55 +02:00
Danny Canter
a2817ca16d CRI: Include sandbox ID in failed to load error
The failed to recover state message didn't include the ID making this
not as useful as it could be..

This additionally moves some of the other logs to include the id for
the sandbox/container as a field instead of part of a format string.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-08-31 10:07:07 -07:00
Sebastiaan van Stijn
4923470902
replace reference/docker for github.com/distribution/reference v0.5.0
The reference/docker package was a fork of github.com/distribution/distribution,
which could not easily be used as a direct dependency, as it brought many other
dependencies with it.

The "reference' package has now moved to a separate repository, which means
we can replace the local fork, and use the upstream implementation again.

The new module was extracted from the distribution repository at commit:
b9b19409cf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-31 15:54:50 +02:00
Jin Dong
fc45365fa1 Remove most logrus
Signed-off-by: Jin Dong <jin.dong@databricks.com>
2023-08-26 14:31:53 -04:00
Akihiro Suda
f48bbef193
Merge pull request #8994 from mxpv/cri
Use sandboxed CRI by default
2023-08-24 13:42:58 +09:00
Maksym Pavlenko
c3f3cad287
Use sandboxed CRI by default
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-08-23 08:50:40 -07:00
Sebastiaan van Stijn
b76cd4d9fd
replace some fmt.Sprintfs with strconv
Teeny-tiny optimizations:

    BenchmarkSprintf-10       37735996    32.31  ns/op  0 B/op  0 allocs/op
    BenchmarkItoa-10         591945836     2.031 ns/op  0 B/op  0 allocs/op
    BenchmarkFormatUint-10   593701444     2.014 ns/op  0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 16:43:02 +02:00
Sebastiaan van Stijn
d7bc8694be
pkg/cri: replace some fmt.Sprintfs with strconv
Teeny-tiny optimizations:

    BenchmarkSprintf-10       37735996    32.31  ns/op  0 B/op  0 allocs/op
    BenchmarkItoa-10         591945836     2.031 ns/op  0 B/op  0 allocs/op
    BenchmarkFormatUint-10   593701444     2.014 ns/op  0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 10:10:56 +02:00
Fu Wei
738c153573
Merge pull request #8992 from djdongjin/remove-hashicorp-multierror
Remove hashicorp/go-multierror dependency
2023-08-23 13:13:51 +08:00
Derek McGowan
2bac6ffb79
Merge pull request #8663 from helen-frank/feature/MergeSortedStringSlices
MergeStringSlices use sets
2023-08-22 16:31:28 -07:00
Phil Estes
de066a37dc
Merge pull request #8935 from lengrongfu/feat/add-metrics-for-dropped-events
add metrics for discarding events
2023-08-22 09:09:31 -04:00
Fu Wei
3ffde050a4
Merge pull request #8988 from kinvolk/rata/userns-fix-platform
cri: Fix sandbox_mode "shim"
2023-08-22 16:40:34 +08:00
Derek McGowan
b8f32e863c
Merge pull request #8951 from kiashok/exposeCommitMemWindows
Populate commit memory for windows memory usage stats
2023-08-21 15:42:34 -07:00
Jin Dong
cd8c8ae4bc Remove hashicorp/go-multierror
Signed-off-by: Jin Dong <jin.dong@databricks.com>
2023-08-20 17:59:45 -07:00
Rodrigo Campos
d09f7cbe00 cri: Fix sandbox_mode "shim"
This is a partial revert of "cri/sbserver: Use platform instead of GOOS
for userns detection".

While what that commit did is 100% the right thing to do, when the
sandbox_mode is "shim" all controller.XXX() calls are RPCs and the
controller.Create() call initializes the controller. Therefore, things
like "getSandboxController()" don't work in the case of "shim"
sandbox_mode until after the controller.Create().

Due to this asymmetry and the lack of tests for shim mode, we didn't
catch it before.

This patch just reverts that commit so that the Create() and
getSandboxController() calls remain where they were, and just relies on
the config Linux section as a hack to detect if the pod sandbox will use
user namespaces or not.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-08-18 15:13:10 +02:00