Commit Graph

1492 Commits

Author SHA1 Message Date
Iceber Gu
a2b16d7f9c cri: fix update of pinned label for images
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
(cherry picked from commit 2e014fa2ac)
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2023-11-16 14:55:23 +08:00
Iceber Gu
8dc8618442 cri: fix using the pinned label to pin image
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
(cherry picked from commit 7f7ba31b64)
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2023-11-16 14:52:35 +08:00
ruiwen-zhao
d62cba40c8 Expose usage of cri-api v1alpha2
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
2023-11-07 23:10:34 +00:00
Samuel Karp
152c57e918 cri: add deprecation warning for configs
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit a596d09ec9)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-02 18:21:30 -07:00
Samuel Karp
689a1036dd cri: add deprecation warning for auths
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 35924bccc0)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-02 18:20:33 -07:00
Samuel Karp
8c38975bf2 cri: add deprecation warning for mirrors
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit d7cb25d770)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-02 18:20:14 -07:00
Samuel Karp
1fbce40c4a cri: add ability to emit deprecation warnings
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 58cc275eb8)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-02 18:05:20 -07:00
Samuel Karp
b708f8bfad deprecation: new package for deprecations
This package enumerates the known deprecations in the current version of
containerd.  New deprecations should be added here, and old ones
removed.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit aff5b809c5)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:11 -07:00
Fu Wei
c12225c6e0 Merge pull request #9168 from AkihiroSuda/cherrypick-9158-1.7
[release/1.7] cri: stop recommending disable_cgroup
2023-10-02 19:37:22 +08:00
Akihiro Suda
171d768493 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>
(cherry picked from commit 5365f4b29e)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-29 20:44:43 -07:00
Akihiro Suda
6013b5e03e 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>
(cherry picked from commit 8ffb03d689)
(cherry-pick was not clean)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-30 12:30:07 +09:00
Aditya Ramani
3d27bc738a 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>
(cherry picked from commit 729c97cf39)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-09-29 19:15:07 -07:00
Kirtana Ashok
c7a35ccdcc Fix transfer service dependencies:
- Fill OSVersion field of ocispec.Platform for windows OS in
transfer service plugin init()
- Do not return error from transfer service ReceiveStream if
stream.Recv() returned context.Canceled error

Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
(cherry picked from commit 823e0420eb)
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
2023-09-08 10:26:37 -07:00
Danny Canter
b449440a40 CRI: Support Linux usernames for !linux platforms
The oci.WithUser option was being applied in container_create_linux.go
instead of the cross plat buildLinuxSpec method. There's been recent
work to try and make every spec option that can be applied on any platform
able to do so, and this falls under that. However, WithUser on linux platforms
relies on the containers SnapshotKey being filled out, which means the spec
option needs to be applied during container creation.

To make this a little more generic, I've created a new platformSpecOpts
method that handles any spec opts that rely on runtime state (rootfs mounted
for example) for some platforms, or just platform options that we still don't
have workarounds for to be able to specify them for other platforms
(apparmor, seccomp etc.) by internally calling the already existing
containerSpecOpts method.

Signed-off-by: Danny Canter <danny@dcantah.dev>
(cherry picked from commit 66307d0b4e)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-08-25 18:21:24 -07:00
Wei Fu
b4f480fb30 pkg/cri/sbserver: fix leaked shim issue for podsandbox mode
Fixes: #7496 #8931

Uses logrus instead of log

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 8dcb2a6e6d)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-08-24 08:26:59 +08:00
Wei Fu
88ff575c5c pkg/cri/server: fix leaked shim issue
Fixes: #7496 #8931

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 72bc63d83d)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-08-24 08:22:37 +08:00
Wei Fu
30a1630869 snapshots|pkg: umount without DETACH and nosync after umount
Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 6dfb16f99a)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-08-18 05:23:08 -07:00
rongfu.leng
c0b1c8f74a fix ci Linux Integration test fail
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
(cherry picked from commit 38f9bc3e0a)
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
2023-08-10 14:48:27 -07:00
Rodrigo Campos
4e97a115f7 cri: Don't use rel path for image volumes
Runc 1.1 throws a warning when using rel destination paths, and runc 1.2
is planning to thow an error (i.e. won't start the container).

Let's just make this an abs path in the only place it might not be: the
mounts created due to `VOLUME` directives in the Dockerfile.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 2d64ab8d79)
2023-08-07 17:25:10 +02:00
Qasim Sarfraz
b461ecacfa 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>
(cherry picked from commit 06f18c69d2)
Signed-off-by: Qasim Sarfraz <qasimsarfraz@microsoft.com>
2023-07-26 18:32:04 +02:00
Phil Estes
68bd89ecbb Merge pull request #8824 from thaJeztah/1.7_backport_fix-additiona-gids-to-read-image-user
[release/1.7 backport] [CRI] fix additionalGids: it should fallback to imageConfig.User when securityContext.RunAsUser,RunAsUsername are empty
2023-07-17 10:54:07 -04:00
Phil Estes
e4c98f895b Merge pull request #8825 from thaJeztah/1.7_backport_issue-8607
[release/1.7 backport] cri: write generated CNI config atomically
2023-07-17 10:53:30 -04:00
Maksym Pavlenko
f7a20e17c3 Move logrus setup code to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
(cherry picked from commit 370be0c18f)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-16 21:33:11 +02:00
Samuel Karp
186eb64b7c 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>
(cherry picked from commit 3c4a1ab1cb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:25:35 +02:00
Samuel Karp
64c3dcd8e2 atomicfile: new package for atomic file writes
Certain files may need to be written atomically so that partial writes
are not visible to other processes. On Unix-like platforms such as
Linux, FreeBSD, and Darwin, this is accomplished by writing a temporary
file, syncing, and renaming over the destination file name. On Windows,
the same operations are performed, but Windows does not guarantee that a
rename operation is atomic.

Partial/inconsistent reads can occur due to:
1. A process attempting to read the file while containerd is writing it
   (both in the case of a new file with a short/incomplete write or in
   the case of an existing, updated file where new bytes may be written
   at the beginning but old bytes may still be present after).
2. Concurrent goroutines in containerd leading to multiple active
   writers of the same file.

The above mechanism explicitly protects against (1) as all writes are to
a file with a temporary name.

There is no explicit protection against multiple, concurrent goroutines
attempting to write the same file. However, atomically writing the file
should mean only one writer will "win" and a consistent file will be
visible.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit f3ba7c8a35)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:25:35 +02:00
Shingo Omura
083f571609 capture desc variable in range variable just in case that it run in parallel mode
Signed-off-by: Shingo Omura <everpeace@gmail.com>
(cherry picked from commit dc2fc987ca)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:18:16 +02:00
Shingo Omura
a9440ce6b5 Use t.TempDir instead of os.MkdirTemp
Signed-off-by: Shingo Omura <everpeace@gmail.com>
(cherry picked from commit 05bb52b273)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:18:08 +02:00
Shingo Omura
eea3440d89 use strings.Cut instead of strings.Split for parsing imageConfig.User
Signed-off-by: Shingo Omura <everpeace@gmail.com>
(cherry picked from commit 50740a1a0c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:17:56 +02:00
Shingo Omura
eace671808 fix userstr for dditionalGids on Linux
It should fallback to imageConfig.User when no securityContext.RunAsUser/RunAsUsername

Signed-off-by: Shingo Omura <everpeace@gmail.com>
(cherry picked from commit 727b254039)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-14 13:17:48 +02:00
wangxiang
6b6b0c8280 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>
(cherry picked from commit 232538b768)
Signed-off-by: sxllwx <scottwangsxll@gmail.com>
2023-07-12 15:14:53 +08:00
Rodrigo Campos
241514815d pkg/cri/server: Test net.ipv4.ping_group_range works with userns
Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit c17d3bdb54)
2023-07-07 11:34:15 +02:00
Rodrigo Campos
801e8c8069 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>
(cherry picked from commit 9bf5aeca77)
2023-07-07 11:28:22 +02:00
Aditi Sharma
699d6701ae Pinned image support
Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
(cherry picked from commit fe4f8bd884)
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
2023-06-21 23:06:54 +00:00
James Sturtevant
58b6b99cd6 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-07 13:10:30 -07:00
Derek McGowan
147aea0de0 Merge pull request #8638 from AkihiroSuda/cherrypick-8606
[release/1.7] Remove cni conf_template deprecation
2023-06-06 09:18:19 -07:00
Akihiro Suda
0b2b964799 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>
(cherry picked from commit 69b451af5a)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-06-03 17:05:43 +09:00
Aditi Sharma
a24267b289 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>
(cherry picked from commit 3ca5b4437e)
> Conflicts:
>	RELEASES.md
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-06-03 17:02:25 +09:00
James Sturtevant
89415fe361 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-02 16:29:26 -07:00
Kazuyoshi Kato
02a00c3099 Merge pull request #8616 from gabriel-samfira/backport-8043
[release/1.7 backport] Mount snapshots on Windows
2023-06-01 19:25:38 -07:00
Kazuyoshi Kato
73ee51276f Merge pull request #8613 from mxpv/sbevents17
[release/1.7] Publish sandbox events
2023-05-31 13:36:48 -07:00
Maksym Pavlenko
e21c8beee6 Post cherry-pick fixes
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-31 11:46:12 -07:00
Maksym Pavlenko
246240f71c Move PLEG event back to CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-31 11:44:52 -07:00
Maksym Pavlenko
16f3726dd6 Generate sandbox exit events from CRI
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-31 11:44:46 -07:00
Maksym Pavlenko
0c8cfb1a7c Move pod sandbox recovery to podsandbox/ package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-31 11:44:34 -07:00
Phil Estes
1418cbbd0b Merge pull request #8584 from henry118/release/1.7
[release/1.7] notify readiness when registered plugins are ready
2023-05-31 09:14:54 -04:00
Paul "TBBle" Hampson
b57424851c Unify testutil.Unmount on Windows and Unix
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-05-31 02:05:35 +03:00
Paul "TBBle" Hampson
b9a8aad451 Implement Windows mounting for bind and windows-layer mounts
Using symlinks for bind mounts means we are not protecting an RO-mounted
layer against modification. Windows doesn't currently appear to offer a
better approach though, as we cannot create arbitrary empty WCOW scratch
layers at this time.

For windows-layer mounts, Unmount does not have access to the mounts
used to create it. So we store the relevant data in an Alternate Data
Stream on the mountpoint in order to be able to Unmount later.

Based on approach in https://github.com/containerd/containerd/pull/2366,
with sign-offs recorded as 'Based-on-work-by' trailers below.

This also partially-reverts some changes made in #6034 as they are not
needed with this mounting implmentation, which no longer needs to be
handled specially by the caller compared to non-Windows mounts.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Based-on-work-by: Michael Crosby <crosbymichael@gmail.com>
Based-on-work-by: Darren Stahl <darst@microsoft.com>
2023-05-31 02:05:27 +03:00
Danny Canter
7851b0a9f2 CRI: Make stats respect sandbox's platform
To further some ongoing work in containerd to make as much code as possible
able to be used on any platform (to handle runtimes that can virtualize/emulate
a variety of different OSes), this change makes stats able to be handled on
any of the supported stat types (just linux and windows). To accomplish this,
we use the platform the sandbox returns from its `Platform` rpc to decide
what format the containers in a given sandbox are returning metrics in, then
we can typecast/marshal accordingly.

Signed-off-by: Danny Canter <danny@dcantah.dev>
(cherry picked from commit 7274e33e38)
2023-05-30 14:55:03 -07:00
Maksym Pavlenko
8d7c340ca8 [sbserver] handle missing cpu stats
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
(cherry picked from commit 79cb4b0000)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-05-30 14:52:39 -07:00
Maksym Pavlenko
d08b2a088c [sbserver] Refactor usageNanoCores be to used for all OSes
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
(cherry picked from commit 464a4977a6)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-05-30 14:52:30 -07:00