Commit Graph

509 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
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
Bryant Biggs
4e6335ebdf vendor: golang.org/x/net@v0.19.0
Partial cherry-pick of 78421616e0 which
updates golang.org/x/net from v0.17.0 to v0.19.0.

full diff: https://github.com/golang/net/compare/v0.17.0...v0.19.0

Signed-off-by: Bryant Biggs <bryantbiggs@gmail.com>
(cherry picked from commit 78421616e0)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-05-13 13:30:04 +00:00
Derek McGowan
00347b7fa5 Add check for unsupported config versions
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-03 00:01:34 -07:00
Derek McGowan
ae9765737a Merge pull request #9834 from neoaggelos/fix/config-relative
[release/1.7] Fix config import relative path glob
2024-04-24 08:20:22 -07:00
Derek McGowan
8fb6bfa717 Add exports to proxy plugin config
Allows external plugins to define exports.

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit e4639ad)
Signed-off-by: Kern Walster <walster@amazon.com>
2024-04-17 18:13:28 +00:00
Derek McGowan
8916e2cf9d Add platform config to proxy plugins
Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit 4e56939)
Signed-off-by: Kern Walster <walster@amazon.com>
2024-04-17 18:07:51 +00:00
Angelos Kolaitis
62e9535f29 Fix config import relative path glob
Previously, resolveImports would apply a glob filter if
the path contained any '*', or otherwise convert relative
paths to absolute. This meant that it was impossible to
specify globs with paths relative to the main config file.

This commit first resolves relative to absolute paths, then
applies the glob filter (if any). A test case is added to ensure
that this now works as expected.

Signed-off-by: Angelos Kolaitis <neoaggelos@gmail.com>
2024-02-17 13:16:32 +02: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
Akihiro Suda
428714e320 go.mod: dario.cat/mergo v1.0.0
https://github.com/imdario/mergo/compare/v0.3.13...v1.0.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 3c6ab04203)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-21 18:47:24 +01: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
Samuel Karp
74a06671ab plugin: record deprecation for dynamic plugins
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 079383dbec)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:13 -07:00
Samuel Karp
fa5f3c91a9 server: add ability to record config deprecations
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 260e71abc4)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:12 -07:00
Samuel Karp
f7880e7f08 pull: record deprecation warning for schema 1
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit bc861b66f9)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:12 -07:00
Samuel Karp
1dd2f2c028 introspection: add support for deprecations
Deprecation warnings are retrieved from the warning service and
returned via the Server RPC.

Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 9aab446733)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:12 -07:00
Samuel Karp
9b7ceee540 warning: new service for deprecations
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit 240733ce2f)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-10-31 17:11:11 -07:00
Derek McGowan
a83c66813f Require plugins to succeed after registering readiness
When readiness is registered on initialization, the plugin must not
fail. When such a plugin fails, containerd will hang on the readiness
condition.

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit e7254406c9)
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-29 20:44:44 -07: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
Derek McGowan
661e505c82 Add proxy differ
Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit 3784c1c917)
Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-08-18 03:05:10 -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
91d9f5c643 Publish sandbox events
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-31 11:43:44 -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
Fu Wei
8cb00f45c9 Merge pull request #8143 from mxpv/log
Add Fields type alias to log package
2023-02-21 10:22:23 +08:00
Maksym Pavlenko
06e085c8b5 Add Fields type alias to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-02-20 17:29:08 -08:00
Zhang Tianyang
56274749c8 sandbox: start sandbox with options
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-02-17 17:14:03 +08:00
Zechun Chen
39bac0dbef error strings should not be capitalized
Signed-off-by: Zechun Chen <zechun.chen@daocloud.io>
2023-02-15 14:30:36 +08:00
Fu Wei
2654ece1d0 Merge pull request #8066 from fuweid/cleanup-blockio-init
*: introduce wrapper pkgs for blockio and rdt
2023-02-13 14:05:32 +08:00
Akihiro Suda
b61988670c go.mod: github.com/containerd/typeurl/v2 v2.1.0
Changes: https://github.com/containerd/typeurl/compare/7f6e6d160d67...v2.1.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-02-11 23:39:52 +09:00
Wei Fu
62df35df66 *: introduce wrapper pkgs for blockio and rdt
Before this patch, both the RdtEnabled and BlockIOEnabled are provided
by services/tasks pkg. Since the services/tasks can be pkg plugin which
can be initialized multiple times or concurrently. It will fire data-race
issue as there is no mutex to protect `enable`.

This patch is aimed to provide wrapper pkgs to use intel/{blockio,rdt}
safely.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-02-10 08:21:34 +08:00
Derek McGowan
34314717b0 Remove sandox store and controller service type
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-02-06 22:05:26 -08:00
Derek McGowan
a788f6c799 Move local sandbox controller under plugins package
Add options to sandbox controller interface.
Update sandbox controller interface to fully utilize sandbox controller
interface.
Move grpc error conversion to service.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-02-06 22:04:45 -08:00
Derek McGowan
2717685dad Refactor sandbox controller interface
Update the sandbox controller interface to use local types rather than
using the API types.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-02-06 21:39:30 -08:00
Maksym Pavlenko
86c238c873 Generate GRPC for runtime sandbox API
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-02-02 09:58:43 -08:00
Edgar Lee
34d5878185 Use mount.Target to specify subdirectory of rootfs mount
- Add Target to mount.Mount.
- Add UnmountMounts to unmount a list of mounts in reverse order.
- Add UnmountRecursive to unmount deepest mount first for a given target, using
moby/sys/mountinfo.

Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
2023-01-27 09:51:58 +08:00
Derek McGowan
beabd3d5d1 Merge pull request #7129 from junnplus/namespace-service
fix incorrect namespace of event when create/update namespace
2023-01-19 22:49:28 -08:00
Maksym Pavlenko
f318e5630b Update sandbox API to return target platform
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-01-11 13:03:59 -08:00
Phil Estes
72e5ddb516 Merge pull request #7886 from dmcgowan/fix-transfer-register-ordering
Fix race between stream registration and use
2023-01-04 14:49:28 -05:00
Akihiro Suda
24a255ce96 Merge pull request #7850 from dmcgowan/sandbox-store-local-plugin
[sandbox] Add sandbox store plugin type
2023-01-04 00:21:06 +09:00
Fu Wei
9a7c264d25 Merge pull request #5674 from dmcgowan/metadata-snapshot-publish 2023-01-03 09:23:48 +08:00
Derek McGowan
d7ef6cbfa3 [streaming] move response packet after registration
Prevent a race where a client may attempt to use a stream
before it is registered.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-12-30 21:56:25 -08:00
Wei Fu
6b7e237fc7 chore: use go fix to cleanup old +build buildtag
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-12-29 14:25:14 +08:00
Derek McGowan
47fee791f6 Add sandbox store plugin type
Moves the sandbox store plugin under the plugins packages and adds a
unique plugin type for other plugins to depend on it.
Updates the sandbox controller plugin to depend on the sandbox store
plugin.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-12-20 23:05:14 -08:00
Derek McGowan
2c573de6d3 Move snapshot event publishing into metadata store
Removes the snapshot event publishing from the snapshot service.

Adds an option to metadata db to add a publisher. Adds event
publishing to prepare, commit, and remove snapshot operations.
Adds remove snapshot event to garbage collection.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-12-19 17:05:28 -08:00
Fu Wei
12f30e6524 Merge pull request #7792 from mxpv/sb-shutdown 2022-12-15 13:37:35 +08:00
Maksym Pavlenko
a4d5c3e5cb Support sandboxed shims shutdown
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-12-14 18:22:52 -08:00
Akihiro Suda
75b09ac4a7 images: support specifying SourceDateEpoch via ctx
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-12-12 09:02:35 +09:00
Maksym Pavlenko
a113737ccf sbserver bug fixing
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-12-06 15:32:42 -08:00