1572 Commits
Author SHA1 Message Date
Shengjing Zhu 09ca004dee Fix TestNewBinaryIOCleanup on Go 1.23 and Linux 5.4
When running the test on Ubuntu focal (kernel version 5.4), the
symlink for pidfd is anon_inode:[pidfd].

Updates: #10345

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
(cherry picked from commit 8ef73c5dd5)
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2024-08-14 16:53:57 +08:00
Phil Estes 716c7b79fb Merge pull request #10575 from dims/borrow-latest-wsstream-from-k8s-v1.31.x-to-1.7
[release/1.7] Borrow latest wsstream from k8s v1.31.x to 1.7
2024-08-13 08:45:42 -04:00
Davanum Srinivas 9269d97b1d hide wsstream under internal/ to prevent external use
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-12 13:54:46 -04:00
Davanum Srinivas 226f93d928 Add copyright headers
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-10 21:12:44 -04:00
Davanum Srinivas 6f3252733c switch over references to the new package
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-10 21:12:40 -04:00
Davanum Srinivas 0a85d476a1 Fix up some constant references
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-10 21:12:35 -04:00
Davanum Srinivas 82bfa44d0f Copy over wsstream from k8s v1.31.0-rc.1 release
SHA: 60c4c2b2521fb454ce69dee737e3eb91a25e0535

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-08-10 21:12:28 -04:00
Chris Henzie 52b79f3377 Update CRIAPIV1Alpha2 warning lastOccurrence every call
This helps gather more accurate API usage data that informs efforts on how to safely migrate containerd clients to 2.0.

Signed-off-by: Chris Henzie <chrishenzie@google.com>
2024-08-09 16:21:02 -07:00
Sebastiaan van Stijn dce0b5a6d3 migrate to github.com/moby/sys/userns
Commit 8437c567d8 migrated the use of the
userns package to the github.com/moby/sys/user module.

After further discussion with maintainers, it was decided to move the
userns package to a separate module, as it has no direct relation with
"user" operations (other than having "user" in its name).

This patch migrates our code to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 9776047243)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 13:10:40 +02:00
Sebastiaan van Stijn 65f7d07409 pkg/userns: deprecate and migrate to github.com/moby/sys/user/userns
The userns package in libcontainer was integrated into the moby/sys/user
module at commit [3778ae603c706494fd1e2c2faf83b406e38d687d][1].

This patch deprecates the containerd fork of that package, and adds it as
an alias for the moby/sys/user/userns package.

[1]: https://github.com/opencontainers/runc/commit/3778ae603c706494fd1e2c2faf83b406e38d687d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 8437c567d8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 13:06:41 +02:00
Mauri de Souza Meneguzzo 3ff82ba0f0 Fix TestNewBinaryIOCleanup failing with gotip
This PR ignores a new pidfd file descriptor that is introduced in
gotip (future 1.23) and should not be considered when detecting fd leaks.

Fixes #10345

Signed-off-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
(cherry picked from commit f0aecaa2e2)
Signed-off-by: Shengjing Zhu <i@zhsj.me>
2024-08-06 18:25:53 +08:00
rongfu.leng 7bb1455d88 update auths code comment
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2024-07-31 22:11:33 +00:00
Kazuyoshi Kato 97a5245ccb Merge pull request #10528 from saschagrunert/10521-1.7
[release/1.7]  Make `StopContainer` RPC idempotent
2024-07-31 10:31:58 -07:00
Sascha Grunert 6da4e40b22 Make StopContainer RPC idempotent
Similar to container removal, the stop of a container should be a noop if
the container has not been found.

Found during: https://github.com/kubernetes-sigs/cri-tools/pull/1536

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
(cherry picked from commit a97b11898a)
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-07-31 09:38:45 +02:00
Sascha Grunert b3b6f15075 Make StopPodSandbox RPC idempotent
Similar to sandbox removal, the stop of a sandbox should be a noop if
the sandbox has not been found.

Found during: https://github.com/kubernetes-sigs/cri-tools/pull/1535

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
(cherry picked from commit c6cea95d95)
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-07-31 09:37:27 +02:00
Samuel Karp 9afb8dcdfe deprecation: update warnings for CRI config fields
Some CRI config properties had removal postponed until v2.1 in
https://github.com/containerd/containerd/pull/9966. Update the
associated deprecation warnings to match the new removal version.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit f9146c0516)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2024-07-26 14:05:15 -07:00
Phil Estes 34ea461d06 Merge pull request #10461 from dims/automated-cherry-pick-of-#8367-upstream-release-1.7
[release/1.7] CRI Sbserver: Make PodSandboxStatus friendlier to shim crashes
2024-07-16 15:35:07 -04:00
Tim Hockin 209ee4f107 CRI: An empty DNSConfig != unspecified
If we find that DNSConfig is provided and empty (not nil), we should not
replace it with the host's resolv.conf.

Also adds tests.

Signed-off-by: Tim Hockin <thockin@google.com>
2024-07-16 12:03:40 -04:00
Danny Canter df86bdd5dc CRI Sbserver: Make PodSandboxStatus friendlier to shim crashes
Currently if you're using the shim-mode sandbox server support, if your
shim that's hosting the Sandbox API dies for any reason that wasn't
intentional (segfault, oom etc.) PodSandboxStatus is kind of wedged.
We can use the fact that if we didn't go through the usual k8s flow
of Stop->Remove and we still have an entry in our sandbox store,
us not having a shim mapping anymore means this was likely unintentional.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2024-07-16 10:17:45 -04:00
Davanum Srinivas 610498df75 Fix for [cri] ttrpc: closed during ListPodSandboxStats
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-07-05 15:55:58 -04:00
Samuel Karp 7f5d3c5f4d cri: ensure NRI API never has nil CRI
A nil CRIImplementation field can cause a nil pointer dereference and
panic during startup recovery.

Prior to this change, the nri.API struct would have a nil cri
(CRIImplementation) field after nri.NewAPI until nri.Register was
called.  Register is called mid-way through initialization of the CRI
plugin, but recovery for containers occurs prior to that.  Container
recovery includes establishing new exit monitors for existing containers
that were discovered.  When a container exits, NRI plugins are given the
opportunity to be notified about the lifecycle event, and this is done
by accessing that CRIImplementation field inside the nri.API.  If a
container exits prior to nri.Register being called, access to the
CRIImplementation field can cause a panic.

Here's the call-path:

* The CRI plugin starts running
  [here](https://github.com/containerd/containerd/blob/ae71819c4f5e67bb4d5ae76a6b735f29cc25774e/pkg/cri/server/service.go#L222)
* It then [calls into](https://github.com/containerd/containerd/blob/ae71819c4f5e67bb4d5ae76a6b735f29cc25774e/pkg/cri/server/service.go#L227)
  `recover()` to recover state from previous runs of containerd
* `recover()` then attempts to recover all containers through
  [`loadContainer()`](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/server/restart.go#L175)
* When `loadContainer()` finds a container that is still running, it waits
  for the task (internal containerd object) to exit and sets up
  [exit monitoring](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/server/restart.go#L391)
* Any exit that then happens must be
  [handled](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/server/events.go#L145)
* Handling an exit includes
  [deleting the Task](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/server/events.go#L188)
  and specifying [`nri.WithContainerExit`](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/nri/nri_api_linux.go#L348)
  to [notify](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/nri/nri_api_linux.go#L356)
  any subscribed NRI plugins
* NRI plugins need to know information about the pod (not just the sandbox),
  so before a plugin is notified the NRI API package
  [queries the Sandbox Store](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/nri/nri_api_linux.go#L232)
  through the CRI implementation
* The `cri` implementation member field in the `nri.API` struct is set as part of the
  [`Register()`](https://github.com/containerd/containerd/blob/ae7d74b9e21bd08260586db104a1fe04af754545/internal/cri/nri/nri_api_linux.go#L66) method
* The `nri.Register()` method is only called
  [much further down in the CRI `Run()` method](https://github.com/containerd/containerd/blob/ae71819c4f5e67bb4d5ae76a6b735f29cc25774e/pkg/cri/server/service.go#L279)

(manually backported from commit 10aec359a0)

Signed-off-by: Samuel Karp <samuelkarp@google.com>
2024-07-01 11:21:06 -07:00
Wei Fu 79500d5cb2 *: export RemoveVolatileOption for CRI image volumes
Remove volatile option when CRI prepares image volumes.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 4123170a39)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-06-13 15:39:44 +08:00
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:
https://github.com/distribution/distribution/commit/b9b19409cf458dcb9e1253ff44ba75bd0620faa6

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
Maksim An 33b62936ea [release/1.7]: HPC working directory fix in pkg/cri/server code
Change in 989f1ec54f assumed a single
place (pkg/cri/sbserver) where this had to be fixed.

Commit in main branch for reference:
(cherry picked from commit c7ea06a69b)

Signed-off-by: Maksim An <maksiman@microsoft.com>
2024-06-06 12:31:54 -07: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
Derek McGowan 32b594f1b2 Update unpacker to always fetch all
When a set of layers are provided to the unpacker, then the unpacker
should still fetch them regardless of whether they will be used for
unpack. The image handler filters are responsible for removing content
which is not intended to be fetched. Currently there is no way to use an
unpacker and also fetch all platforms.

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit 681a083fab)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-15 11:54:54 -07:00
Akihiro Suda 189b69e247 go.mod: github.com/opencontainers/image-spec v1.1.0-rc3
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 4347fc8bc2)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-06 17:12:52 -07:00
Derek McGowan c4a86424ff Merge pull request #10096 from Kern--/cri-remote-snapshotter-stats
[release/1.7] Fix CRI snapshotter root path when not under containerd root
2024-04-23 10:51:29 -07: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
Danny Canter a8ebceb972 CRI: "Fix" imageFSPath behavior
Currently it didn't take into account that certain snapshots can explicitly
have their root directories placed at a different location. This changes
it to use the RootPath method of the snapshotter if it implements it.

Without this change, cadvisor is not able to get filesystem usage
information, which prevents the kubelet from doing image garbage
collection and enforcing ephemeral storage limits.

Signed-off-by: Danny Canter <danny@dcantah.dev>
(cherry picked from commit 6aeec45)
Signed-off-by: Kern Walster <walster@amazon.com>
2024-04-18 23:33:25 +00: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
Phil Estes fc4b00de18 Merge pull request #10063 from sctb512/cherry-pick-10021-to-1.7
[release/1.7] fix(cri): fix unexpected order of mounts since go 1.19
2024-04-12 14:21:31 -04:00
Maksym Pavlenko 70cf68b82c Merge pull request #9989 from hinshun/backport/1.7-pr9864
[release/1.7] Automatically decompress archives for transfer service import
2024-04-11 10:26:47 -07:00
Bin Tang 9f774e438b fix(cri): fix unexpected order of mounts since go 1.19
Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
2024-04-11 14:22:18 +08:00
Phil Estes 6e2411fd8a Merge pull request #9992 from vvoland/vrelease/1.7-8970
[release 1.7] Add support for configuring otel from env and config deprecation notice
2024-04-08 13:11:11 -04:00
Danny Canter 90c309fe2f Add IsNotFound case to ListPodSandboxStats
Fixes #10013. It seems we can end up in a spot where the sandbox store still
has a listing for a pod, whereas containerds underlying store has removed it.
It might be better to shield the caller (k8s) from these transient errors.

Signed-off-by: Danny Canter <danny@dcantah.dev>
(cherry picked from commit 2474a99c30)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2024-04-05 11:35:53 -07:00
Brian Goff f2354894f3 Deprecate otel configs
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 753a525b3b)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-25 17:04:24 +01:00
Edgar Lee 2aec52493f Automatically decompress archives for transfer service import
Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
2024-03-24 02:17:19 +08: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