Commit Graph
570 Commits
Author SHA1 Message Date
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
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
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
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
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
Akihiro Suda c79ffa2773 cri: propagate deprecation list to runtime status
Propagate the deprecation list to CRI runtime conditions.

The propagated conditions are visible via `crictl info`,
but not visible via `kubectl get nodes -o yaml` yet, although
the CRI API says "These conditions will be exposed to users to help
them understand the status of the system".

https://github.com/kubernetes/cri-api/blob/v0.29.1/pkg/apis/runtime/v1/api.proto#L1505-L1509

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 1b3a96da6c)
(cherry-pick was not clean)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-02-14 15:18:55 +09: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
Wei Fu ea0a92ec30 *: introduce image_pull_with_sync_fs in CRI
It's to ensure the data integrity during unexpected power failure.

Background:

Since release 1.3, in Linux system, containerD unpacks and writes files into
overlayfs snapshot directly. It doesn’t involve any mount-umount operations
so that the performance of pulling image has been improved.

As we know, the umount syscall for overlayfs will force kernel to flush
all the dirty pages into disk. Without umount syscall, the files’ data relies
on kernel’s writeback threads or filesystem's commit setting (for
instance, ext4 filesystem).

The files in committed snapshot can be loss after unexpected power failure.
However, the snapshot has been committed and the metadata also has been
fsynced. There is data inconsistency between snapshot metadata and files
in that snapshot.

We, containerd, received several issues about data loss after unexpected
power failure.

* https://github.com/containerd/containerd/issues/5854
* https://github.com/containerd/containerd/issues/3369#issuecomment-1787334907

Solution:

* Option 1: SyncFs after unpack

Linux platform provides [syncfs][syncfs] syscall to synchronize just the
filesystem containing a given file.

* Option 2: Fsync directories recursively and fsync on regular file

The fsync doesn't support symlink/block device/char device files. We
need to use fsync the parent directory to ensure that entry is
persisted.

However, based on [xfstest-dev][xfstest-dev], there is no case to ensure
fsync-on-parent can persist the special file's metadata, for example,
uid/gid, access mode.

Checkout [generic/690][generic/690]: Syncing parent dir can persist
symlink. But for f2fs, it needs special mount option. And it doesn't say
that uid/gid can be persisted. All the details are behind the
implemetation.

> NOTE: All the related test cases has `_flakey_drop_and_remount` in
[xfstest-dev].

Based on discussion about [Documenting the crash-recovery guarantees of Linux file systems][kernel-crash-recovery-data-integrity],
we can't rely on Fsync-on-parent.

* Option 1 is winner

This patch is using option 1.

There is test result based on [test-tool][test-tool].
All the networking traffic created by pull is local.

  * Image: docker.io/library/golang:1.19.4 (992 MiB)
    * Current: 5.446738579s
      * WIOS=21081, WBytes=1329741824, RIOS=79, RBytes=1197056
    * Option 1: 6.239686088s
      * WIOS=34804, WBytes=1454845952, RIOS=79, RBytes=1197056
    * Option 2: 1m30.510934813s
      * WIOS=42143, WBytes=1471397888, RIOS=82, RBytes=1209344

  * Image: docker.io/tensorflow/tensorflow:latest (1.78 GiB, ~32590 Inodes)
    * Current: 8.852718042s
      * WIOS=39417, WBytes=2412818432, RIOS=2673, RBytes=335987712
    * Option 1: 9.683387174s
      * WIOS=42767, WBytes=2431750144, RIOS=89, RBytes=1238016
    * Option 2: 1m54.302103719s
      * WIOS=54403, WBytes=2460528640, RIOS=1709, RBytes=208237568

The Option 1 will increase `wios`. So, the `image_pull_with_sync_fs` is
option in CRI plugin.

[syncfs]: <https://man7.org/linux/man-pages/man2/syncfs.2.html>
[xfstest-dev]: <https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git>
[generic/690]: <https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/tests/generic/690?h=v2023.11.19>
[kernel-crash-recovery-data-integrity]: <https://lore.kernel.org/linux-fsdevel/1552418820-18102-1-git-send-email-jaya@cs.utexas.edu/>
[test-tool]: <https://github.com/fuweid/go-dmflakey/blob/a17fb2010db22654b3e54cf506b0dbb5ef7b33ca/contrib/syncfs/containerd/main_test.go#L51>

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 23278c81fb)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-02-06 14:42:13 +08:00
Kirtana Ashok 3f75af7bf2 Move certain debug logs to trace logs
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
(cherry picked from commit f261969507)
2024-02-05 15:57:57 -08: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
Samuel Karp 467de562c1 Merge pull request #9481 from ruiwen-zhao/cri-u
[release/1.7] Add warning for CRIU config usage
2023-12-07 01:28:28 -08:00
ruiwen-zhao 1fdefdd224 Add warning for CRIU config usage
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
2023-12-07 00:08:14 +00:00
Derek McGowan 8e0689938a Merge pull request #9479 from ruiwen-zhao/cri-api-warning
[release/1.7] Add cri-api v1alpha2 usage warning to all api calls
2023-12-06 13:32:47 -08:00
ruiwen-zhao dc45bc8381 Add cri-api v1alpha2 usage warning to all api calls
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
2023-12-06 18:30:02 +00:00
Samuel Karp 51a604c073 cri: add deprecation warning for runtime_root
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:28:08 -08:00
Samuel Karp 8040e74bf8 cri: add deprecation warning for rutnime_engine
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:28:07 -08:00
Samuel Karp 99adc40eb2 cri: add deprecation warning for default_runtime
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:28:07 -08:00
Samuel Karp afef7ec646 cri: add warning for untrusted_workload_runtime
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:28:07 -08:00
Samuel Karp 6220dc1909 cri: add warning for old form of systemd_cgroup
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:27:38 -08:00
Wei Fu 2068061289 remotes/docker: close connection if no more data
Close connection if no more data. It's to fix false alert filed by image
pull progress.

```
dst = OpenWriter (--> Content Store)

src = Fetch
        Open (--> Registry)
        Mark it as active request

Copy(dst, src) (--> Keep updating total received bytes)

   ^
   |  (Active Request > 0, but total received bytes won't be updated)
   v

defer src.Close()
content.Commit(dst)
```

Before migrating to transfer service, CRI plugin doesn't limit global
concurrent downloads for ImagePulls. Each ImagePull requests have 3 concurrent
goroutines to download blob and 1 goroutine to unpack blob. Like ext4
filesystem [1][1], the fsync from content.Commit may sync unrelated dirty pages
into disk. The host is running under IO pressure, and then the content.Commit
will take long time and block other goroutines. If httpreadseeker
doesn't close the connection after io.EOF, this connection will be
considered as active. The pull progress reporter reports there is no
bytes transfered and cancels the ImagePull.

The original 1-minute timeout[2][2] is from kubelet settting. Since CRI-plugin
can't limit the total concurrent downloads, this patch is to update 1-minute
to 5-minutes to prevent from unexpected cancel.

[1]: https://lwn.net/Articles/842385/
[2]: https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/kubelet/config/flags.go#L45-L48

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-11-21 23:31:42 +00:00
Wei Fu d1aab27cbd fix: deflake TestCRIImagePullTimeout/HoldingContentOpenWriter
The new active request is filed and there is no bytes read yet when the
progress reporter just wakes up. If the timeout / 2 is less than the
minPullProgressReportInternal, it's easy to file false alert.

We should remove the minPullProgressReportInternal limit.

Fixes: #8024

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-11-21 23:12:14 +00:00
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
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
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
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