Commit Graph

1534 Commits

Author SHA1 Message Date
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
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
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
Fu Wei
c558dc5cf2 Merge pull request #9837 from hinshun/backport/8945-and-9028
[release/1.7] Add WithMetaStore to overlay snapshotter and missing unpacker.Wait for image import
2024-02-22 11:16:15 +08:00
Edgar Lee
8fe0b26f19 Add missing unpacker.Wait for image import
- For remote snapshotters, the unpack phase serves as an important step for
  preparing the remote snapshot. With the missing unpacker.Wait, the
  snapshotter `Prepare` context is always canceled.
- This patch allows remote snapshotter based archives to be imported via
  the transfer service or `ctr image import`

Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
2024-02-18 02:48:54 -05: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]: <a17fb2010d/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
Sebastiaan van Stijn
2ad2a2e835 switch back from golang.org/x/sys/execabs to os/exec (go1.19)
This is effectively a revert of 2ac9968401, which
switched from os/exec to the golang.org/x/sys/execabs package to mitigate
security issues (mainly on Windows) with lookups resolving to binaries in the
current directory.

from the go1.19 release notes https://go.dev/doc/go1.19#os-exec-path

> ## PATH lookups
>
> Command and LookPath no longer allow results from a PATH search to be found
> relative to the current directory. This removes a common source of security
> problems but may also break existing programs that depend on using, say,
> exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe) in
> the current directory. See the os/exec package documentation for information
> about how best to update such programs.
>
> On Windows, Command and LookPath now respect the NoDefaultCurrentDirectoryInExePath
> environment variable, making it possible to disable the default implicit search
> of “.” in PATH lookups on Windows systems.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2af6db672e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-05 10:09:39 +01:00
Samuel Karp
03fed557e3 restart: containerd.io/restart.logpath warning
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-20 21:43:43 -08:00
Anthony Nandaa
68d2373926 fix(pkg/dialer): minor fix on dialer function for windows
This commit fixes the dialer function to make sure that
"npipe://" prefix is trimmed, just like the way it is done
in the Unix counterpart, `./dialer_unix.go:50`

This will also unblock some downstream work going on in
buildkit; setting up integration tests to run on Windows.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2023-12-11 11:12:58 -08: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
9d1bad62e1 deprecation: fix missing spaces in warnings
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-12-05 22:28:08 -08: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
Samuel Karp
f471bb2b8e tasks: emit warning for runc v1 runtime
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-30 23:33:31 -08:00
Samuel Karp
329e1d487e tasks: emit warning for v1 runtime
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-30 23:18:27 -08:00
Samuel Karp
625b35e4bb snapshots: emit deprecation warning for aufs
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-11-29 01:15:43 -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
Phil Estes
b1c6f01cec Merge pull request #9381 from Iceber/fix_pin_image_1.7
[release/1.7] cri: fix using the pinned label to pin image
2023-11-17 09:28:12 -05: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
Austin Vazquez
5930a3750c Enhance container image unpack client logs
Adds debug message per layer unpacking and adds duration field to
the existing image unpacking debug message.

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
(cherry picked from commit 01c442147f)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2023-11-15 21:37:29 -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