Commit Graph

204 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
6ff3e09d20 migrate platforms package to github.com/containerd/platforms
This updates the platforms package to be an alias for the new platforms module.
This helps transitioning consumers to the new module, and makes sure that
containerd v2 and v1 use the same definitions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 00:58:28 +02:00
Sebastiaan van Stijn
b38c0f2ef8 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>
(cherry picked from commit 4923470902)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 18:26:31 +02:00
Sebastiaan van Stijn
1e3c662d6c [release/1.7] remove uses of platforms.Platform alias
Commit 3c8469a782 removed uses of the api
types.Platform type from public interfaces, instead using the type from
the OCI image spec.

For convenience, it also introduced an alias in the platforms package.
While this alias allows packages that already import containerd's
platforms package (now a separate module), it may also cause confusion
(it's not clear that it's an alias for the OCI type), and for packages
that do not depend on containerd's platforms package / module may now
be resulting in an extra dependency.

Let's remove the use of this alias, and instead use the OCI type directly.

Equivalent of 446e63579c in main.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-28 22:59:44 +02:00
Sebastiaan van Stijn
0af6825b1e migrate logs imports to github.com/containerd/log module
Import the log module directly, instead of using the aliases that are
provided in the log package. This helps find code-paths that still depend
on the old location, and that haven't migrated yet to the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 14:38:51 +02:00
Sebastiaan van Stijn
308341a446 replace uses of github.com/containerd/containerd/errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-26 13:21:40 +02:00
张钰10307750
293f5151d4 pod: CreatedAt time will be 269 years ago while creating cri network failed.
We should set sandbox CreatedAt first time when we create sandbox struct,
   and then set sandbox CreatedAt second time after container started.

   Before this commit, we just set sandbox CreatedAt after container
   started, but if network create failed, the sandbox time is the
   default time, which is 269 years ago, so we need to set sandbox
   CreatedAt at first, even if an error occurred before start container.

Signed-off-by: zzzzzzzzzy9 <zhang.yu58@zte.com.cn>
(cherry picked from commit b16d467404)
There was no merge conflict, but the commit was amended to cover
sbserver.
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-04-23 23:37:55 +09:00
Fu Wei
b4ae688ef5 Merge pull request #10008 from kiashok/supportHPC-portFwd-1.7 2024-04-23 12:49:24 +08:00
Derek McGowan
c37fe74c7d Merge pull request #9865 from kinvolk/rata/userns-update-podSandboxStatus-1.7
[release/1.7]  Include userns info in cri/server PodSandboxStatus
2024-04-22 08:22:31 -07:00
Kirtana Ashok
3df5d4445b Add support for HPC port forwarding
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
2024-04-19 11:32:01 -07:00
Evan Lezar
7a2f49f70f Bump tags.cncf.io/container-device-interface to v0.7.2
This includes migrating from cdi.GetRegistry() to cdi.Configure() and
using top-level cdi Refresh and InjectDevices functions as applicable.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2024-04-18 16:42:04 +02:00
Maksim An
989f1ec54f fix default working directory hostProcess
Per https://github.com/kubernetes/enhancements/tree/master/keps/sig-windows/1981-windows-privileged-container-support#container-mounts
the default working directory for `hostProcess` containers should
be `C:\hpc`, however the current default is set to windows default
which is `C:\`.

Signed-off-by: Maksim An <maksiman@microsoft.com>
(cherry picked from commit c7ea06a69b)
2024-04-12 13:34:37 -07:00
Derek McGowan
33b3e13e61 Merge pull request #9855 from ialidzhikov/cherry-pick-8337-to-release/1.7
[release/1.7] Register imagePullThroughput and count with MiB
2024-03-01 06:16:02 -08:00
Derek McGowan
94fed20205 Merge pull request #9900 from akhilerm/cherry-pick-9800-1.7
[release/1.7] Update golangci-lint to v1.56.1
2024-03-01 06:14:40 -08:00
Kohei Tokunaga
b16ca72b2e Bump up golangci-lint to v1.54.2
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
(cherry picked from commit 6e2c915a44)
Signed-off-by: Akhil Mohan <akhil.mohan@broadcom.com>
2024-03-01 14:46:21 +05:30
Davanum Srinivas
39db3f18b2 adjust test cases to run for windows
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-02-29 22:57:20 -05:00
James Sturtevant
579d8b463b [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>
2024-02-29 22:17:22 -05:00
Rodrigo Campos
b57dc9fd36 cri/server: Add userns tests in PodSandboxStatus
The cherry-pick has been amended to duplicate the tests in cri/sbserver and
cri/server.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 06ed897b22)
2024-02-28 15:36:20 -03:00
Rodrigo Campos
6e809ef13a cri: Expose userns in PodSandboxStatus rpc
We added support for userns but we weren't showing it in the
podSandboxStatus.

Let's just show the whole nsOpts, so we don't forget in the future
either if something else inside there changes.

Please note that this will expose the content of nsOpts.TargetId that we
weren't exposing before. But that seemed like a bug to me.

The cherry-pick has been amended to do the change in cri/sbserver and
cri/server.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
(cherry picked from commit 6c356a5c75)
2024-02-28 11:38:09 -03:00
Shukui Yang
711cebd484 Register imagePullThroughput and count with MiB
Signed-off-by: Shukui Yang <yangshukui@bytedance.com>
(cherry picked from commit db223271e3)
2024-02-26 09:31:47 +02:00
Henry Wang
26c057423c bug fix: make sure cri image is pinned when it is pulled outside cri
Signed-off-by: Henry Wang <henwang@amazon.com>
(cherry picked from commit 1eaf0c1f04)
2024-02-07 21:24:23 +00:00
Evan Lezar
14628d4aaa Update container-device-interface to v0.6.2
This includes migrating from the github.com/container-orchestrated-devices
repo to tags.cncf.io.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2024-01-24 14:51:15 +01: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
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
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
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
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
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
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
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
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
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
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
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
Henry Wang
2c38cad77c notify readiness when registered plugins are ready
Signed-off-by: Henry Wang <henwang@amazon.com>
(cherry picked from commit 4bfcac85fa)
2023-05-27 00:33:05 +00:00
Ed Bartosh
6a5e54c15a Get CDI devices from CRI Config.CDIDevices field
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
(cherry picked from commit cd16b31cd2)
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
2023-05-16 18:49:49 +03:00