Commit Graph

592 Commits

Author SHA1 Message Date
Iceber Gu
7f7ba31b64 cri: fix using the pinned label to pin image
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-07-26 12:26:00 +08:00
Qasim Sarfraz
06f18c69d2 cri: memory.memsw.limit_in_bytes: no such file or directory
If kubelet passes the swap limit (default memory limit = swap limit ),
it is configured for container irrespective if the node supports swap.

Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
2023-07-21 14:43:33 +02:00
Kazuyoshi Kato
ef1c9f0a63
Merge pull request #8766 from lengrongfu/fix/ci-Integration-fail
fix ci Linux Integration test fail
2023-07-18 10:18:12 -07:00
Phil Estes
a94918b591
Merge pull request #8803 from kinvolk/rata/userns-sbserver
cri/sbserver: Add support for user namespaces (KEP-127)
2023-07-17 10:57:01 -04:00
Sebastiaan van Stijn
9c673f9673
pkg/cri/server: TestImageGetLabels: use registry.k8s.io
These are not actually being pulled, just removing the deprecated k8s.gcr.io
from the code-base. While at it, also renamed / removed vars that shadowed
with package-level definitions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 11:22:39 +02:00
Mike Brown
3ed1bc108f
Merge pull request #8671 from jsturtevant/fix-windows-edge-cases
[cri] Handle pod transition states gracefully while listing pod stats
2023-07-12 15:43:21 -05:00
James Sturtevant
f914edf4f6
[cri] Handle Windows pod transitions gracefully
When the pods are transitioning there are several
cases where containers might not be in valid state.
There were several cases where the stats where
failing hard but we should just continue on as
they are transient and will be picked up again
when kubelet queries for the stats again.

Signed-off-by: James Sturtevant <jstur@microsoft.com>

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
2023-07-12 09:57:14 -07:00
Rodrigo Campos
9160386ecc cri/sbserver: Test net.ipv4.ping_group_range works with userns
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:25 +02:00
Rodrigo Campos
1c6e268447 cri/sbserver: Fix net.ipv4.ping_group_range with userns
This commit just updates the sbserver with the same fix we did on main:
	9bf5aeca77 ("cri: Fix net.ipv4.ping_group_range with userns ")

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:25 +02:00
Rodrigo Campos
36a96d7f32 cri/sbserver: Remap snapshots for sbserver too
This is a port of 31a6449734 ("Add capability for snapshotters to
declare support for UID remapping") to sbserver.

This patch remaps the rootfs in the platform-specific if user namespaces
are in use, so the pod can read/write to the rootfs.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:15:22 +02:00
Rodrigo Campos
508e6f6e03 cri/sbserver: Add userns tests to TestLinuxSandboxContainerSpec()
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
fb9ce5d482 cri/sbserver: Support pods with user namespaces
This patch requests the OCI runtime to create a userns when the CRI
message includes such request.

This is an adaptation of a7adeb6976 ("cri: Support pods with user
namespaces") to sbserver, although the container_create.go parts were
already ported as part of 40be96efa9 ("Have separate spec builder for
each platform"),

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
c99cb95f07 cri/sbserver: Let OCI runtime create netns when userns is used
This commit just ports 36f520dc04 ("Let OCI runtime create netns when
userns is used") to sbserver.

The CNI network setup is done after OCI start, as it didn't seem simple
to get the sandbox PID we need for the netns otherwise.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:42 +02:00
Rodrigo Campos
73c75e2c73 cri/sbserver: Copy userns helpers to podsandbox
Currently there is a big c&p of the helpers between these two folders
and a TODO in the platform agnostic file to organize them in the future,
when some other things settle.

So, let's just copy them for now.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 15:14:12 +02:00
Rodrigo Campos
0b6a0fe773 cri/sbserver: Move runtimeStart to match position with cri/server
Commit c085fac1e5 ("Move sandbox start behind controller") moved the
runtimeStart to only account for time _after_ the netns has been
created.

To match what we currently do in cri/server, let's move it to just after
the get the sandbox runtime.

This come up when porting userns to sbserver, as the CNI network setup
needs to be done at a later stage and runtimeStart was accounting for
the CNI network setup time only when userns is enabled.

To avoid that discrepancy, let's just move it earlier, that also matches
what we do in cri/server.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 13:58:45 +02:00
Rodrigo Campos
9d9903565a cri: Fix comment typos
Beside the "in future the when" typo, we take the chance to reflect that
user namespaces are already merged.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-11 13:58:45 +02:00
wangxiang
232538b768 bugfix(port-forward): Correctly handle known errors
These two errors can occur in the following scenarios:

ECONNRESET: the target process reset connection between CRI and itself.
see: #111825 for detail

EPIPE: the target process did not read the received data, causing the
buffer in the kernel to be full, resulting in the occurrence of Zero Window,
then closing the connection (FIN, RESET)
see: #74551 for detail

In both cases, we should RESET the httpStream.

Signed-off-by: wangxiang <scottwangsxll@gmail.com>
2023-07-11 11:06:13 +08:00
rongfu.leng
38f9bc3e0a fix ci Linux Integration test fail
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-07-07 14:51:04 +08:00
Rodrigo Campos
c17d3bdb54 pkg/cri/server: Test net.ipv4.ping_group_range works with userns
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-06 14:20:26 +02:00
Rodrigo Campos
9bf5aeca77 pkg/cri/server: Fix net.ipv4.ping_group_range with userns
userns.RunningInUserNS() checks if the code calling that function is
running inside a user namespace. But we need to check if the container
we will create will use a user namespace, in that case we need to
disable the sysctl too (or we would need to take the userns mapping into
account to set the IDs).

This was added in PR:
        https://github.com/containerd/containerd/pull/6170/

And the param documentation says it is not enabled when user namespaces
are in use:
        https://github.com/containerd/containerd/pull/6170/files#diff-91d0a4c61f6d3523b5a19717d1b40b5fffd7e392d8fe22aed7c905fe195b8902R118

I'm not sure if the intention was to disable this if containerd is
running inside a userns (rootless, if that is even supported) or just
when the pod has user namespaces.

Out of an abundance of caution, I'm keeping the userns.RunningInUserNS()
so it is still not used if containerd runs inside a user namespace.

With this patch and "enable_unprivileged_icmp = true" in the config,
running containerd as root on the host, pods with user namespaces start
just fine. Without this patch they fail with:
        ... failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: w
 /proc/sys/net/ipv4/ping_group_range: invalid argument: unknown

Thanks a lot to Andy on the k8s slack for reporting the issue. He also
mentions he hits this with k3s on a default installation (the param
is off by default on containerd, but k3s turns that on by default it
seems). He also debugged which part of the stack was setting that
sysctl, found the PR that added this code in containerd and a workaround
(to turn the bool off).

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2023-07-06 14:20:26 +02:00
Danny Canter
dfd7ad8b37 Reword Windows file related TODO
https://github.com/golang/go/issues/32088 was never accepted or implemented
in 1.14.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-23 05:42:44 -07:00
Markus Lehtonen
f60a4a2718 cri: drop unused arg from generateRuntimeOptions
Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
2023-06-19 16:11:36 +03:00
Danny Canter
d278d37caa Sandbox: Add Metrics rpc for controller
As a follow up change to adding a SandboxMetrics rpc to the core
sandbox service, the controller needed a corresponding rpc for CRI
and others to eventually implement.

This leaves the CRI (non-shim mode) controller unimplemented just to
have a change with the API addition to start.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-13 00:24:09 -07:00
Derek McGowan
dd5e9f6538
Merge pull request #7944 from adisky/new-pinned-image
CRI Pinned image support
2023-06-10 22:29:34 -07:00
Derek McGowan
98b7dfb870
Merge pull request #8673 from thaJeztah/no_any
avoid "any" as variable name
2023-06-10 20:44:30 -07:00
Sebastiaan van Stijn
4bb709c018
avoid "any" as variable name
Avoid shadowing / confusion with Go's "any" built-in type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-10 13:49:06 +02:00
Sebastiaan van Stijn
577696f608
replace some basic uses of fmt.Sprintf()
Really tiny gains here, and doesn't significantly impact readability:

    BenchmarkSprintf
    BenchmarkSprintf-10    11528700     91.59 ns/op   32 B/op  1 allocs/op
    BenchmarkConcat
    BenchmarkConcat-10    100000000     11.76 ns/op    0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-10 13:24:43 +02:00
Kazuyoshi Kato
326cd0623e
Merge pull request #8362 from gabriel-samfira/fix-non-c-volume
Fix non C volumes on Windows
2023-06-08 21:07:23 -07:00
Gabriel Adrian Samfira
6dd529e400
Pass in imagespec.Platform to WithVolumes()
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-06-08 12:31:04 +03:00
Phil Estes
0a821b968c
Merge pull request #8633 from jsturtevant/fix-for-init-containers-windows-pod-stats
[CRI] Windows Pod Stats: Add a check to skip stats for containers that are not running.
2023-06-07 13:29:27 -04:00
James Sturtevant
28a5199ff6
Add a check to skip stats for containers that are not running
When a container is just created, exited state the container will not have stats. A common case for this in k8s is the init containers for a pod. The will be present in the listed containers but will not have a running task and there for no stats.

Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-06 12:59:56 -07:00
Akihiro Suda
1f54e8fb21
Merge pull request #8637 from AkihiroSuda/followup-8606
RELEASES.md: de-deprecation of CNI conf_template will be v1.7.3
2023-06-06 17:19:41 +09:00
Samuel Karp
f92e576f6b
Merge pull request #8609 from samuelkarp/issue-8607 2023-06-05 10:31:45 -07:00
Akihiro Suda
69b451af5a
RELEASES.md: de-deprecation of CNI conf_template will be v1.7.3
Cherry-pick of PR 8606 missed the v1.7.2 milestone

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-06-03 17:04:14 +09:00
Samuel Karp
3c4a1ab1cb
cri: write generated CNI config atomically on Unix
The 10-containerd-net.conflist file generated from the conf_template
should be written atomically so that partial writes are not visible to
CNI plugins. Use the new consistentfile package to ensure this on
Unix-like platforms such as Linux, FreeBSD, and Darwin.

Fixes https://github.com/containerd/containerd/issues/8607

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-06-02 16:56:34 -07:00
Aditi Sharma
fe4f8bd884 Pinned image support
Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
2023-06-02 09:57:22 +05:30
James Sturtevant
738c4c6fa5
Fix issue for HPC pod metrics
The initial PR had a check for nil metrics but after some refactoring in the PR the test case that was suppose cover HPC was missing a scenario where the metric was not nil but didn't contain any metrics. This fixes that case and adds a testcase to cover it.

Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-01 15:12:36 -07:00
Kazuyoshi Kato
73645b1dfe
Merge pull request #8588 from lengrongfu/feat/cleanup_config_tls
Cleanup DEPRECATED TLS config
2023-05-31 18:50:54 -07:00
Kazuyoshi Kato
3ad032e9d0
Merge pull request #8606 from adisky/remove-conf-template-deprecation
Remove cni conf_template deprecation
2023-05-31 09:47:21 -07:00
Evan Lezar
d3887b2e62 Support CDI devices in ctr --device flag
This change adds support for CDI devices to the ctr --device flag.
If a fully-qualified CDI device name is specified, this is injected
into the OCI specification before creating the container.

Note that the CDI specifications and the devices that they represent
are local and mirror the behaviour of linux devices in the ctr command.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2023-05-31 16:14:01 +02:00
Phil Estes
80eb76332e
Merge pull request #8602 from mxpv/sbevents
Publish sandbox events
2023-05-31 09:14:08 -04:00
Akihiro Suda
65bca439a9
Merge pull request #8599 from lengrongfu/doc/update-auths-code-comment
update auths code comment
2023-05-31 22:13:54 +09:00
Aditi Sharma
3ca5b4437e Remove cni conf_template deprecation
As discussed in the issue
https://github.com/containerd/containerd/issues/8596
It is a helpful feature at many places and no replacement
readily available

Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
2023-05-31 17:34:33 +05:30
rongfu.leng
d2b7a1e293 cleanup DEPRECATED TLS config
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-05-31 09:37:41 +08:00
Maksym Pavlenko
f857626d64 Move PLEG event back to CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-30 16:40:58 -07:00
Maksym Pavlenko
fc50334ca9 Generate sandbox exit events from CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-30 16:40:58 -07:00
Maksym Pavlenko
cf56054594 Move pod sandbox recovery to podsandbox/ package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-30 13:54:35 -07:00
Derek McGowan
6d7060099b
Merge pull request #8552 from dcantah/cross-plat-stats
CRI: Make stats respect sandbox's platform
2023-05-30 09:58:50 -07:00
rongfu.leng
314d758fa1 update auths code comment
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-05-30 23:05:48 +08:00
rongfu.leng
9287711b7a upgrade registry.k8s.io/pause version
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2023-05-28 07:59:10 +08:00