Commit Graph

1550 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
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
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
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