Commit Graph

101 Commits

Author SHA1 Message Date
Henry Wang
0198b87fcf Implement parallel unpack
Signed-off-by: Henry Wang <henwang@amazon.com>
2025-10-24 17:54:26 +00:00
Tonis Tiigi
a7d26b35ec client: add referrers support to client
Allows management of referrer objects when performing
pull, archive export and archive import.

Referrer objects are linked to their subjects via GC
labels. The label is based on sha256 checksum of the
object instead of incremental numbers as referrers are
not immutable and don't have any strict order.

In OCI-layout referrers that are not already in the exported
tree are added to the main index.json with
io.containerd.manifest.subject annotation.

On import such descriptors with that annotation
do not create digest-based images in the image store.

Note that this does not mean all the referrer objects in
the registry are now pulled/exported/imported by default.
The caller of the client pkg functions can choose which
referrer objects should also be handled.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-10-17 13:43:36 -07:00
Derek McGowan
843aee8d3f Merge pull request #12342 from dmcgowan/fix-sandbox-client
Fixes for sandbox client
2025-10-03 20:39:45 +00:00
Derek McGowan
f0aeb9037e Add sandbox controller create call to client
Currently the new sandbox returns a sandbox client which will error when
start is called. The new sandbox should also create the sandbox with the
sandbox controller.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-01 16:04:37 -07:00
Derek McGowan
a338d8b2fb Fix sandbox client shutdown to ignore not found errors
The logic is reversed, not found errors should be ignored

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-01 16:04:36 -07:00
Derek McGowan
54ba402a29 Add default sandboxer to client
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-10-01 16:04:36 -07:00
Derek McGowan
563b28154c Add mount manager to client
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-09-29 17:08:33 -07:00
Derek McGowan
f8fc4698ae Merge pull request #11509 from vvoland/client-lazy-runtime
client/New: Don't unlazy the gRPC connection implicitly
2025-07-09 17:20:02 +00:00
Adrien Delorme
e2d6a71605 cri: put limiter out of config
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-05-04 20:33:35 +02:00
Adrien Delorme
ca356e46ee cri: add a ConcurrentDownloadLimiter
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-30 10:20:26 +02:00
Adrien Delorme
a914597c0f fix: client pull: pass fetch performances options
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-30 10:20:26 +02:00
Adrien Delorme
413702b7e4 fix comment
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-30 10:20:26 +02:00
Adrien Delorme
72c8c7708c only keep one setting: concurrent_layer_fetch_buffer
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-24 11:41:33 +02:00
Adrien Delorme
024775dab1 set dl options on resolver
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-24 11:41:33 +02:00
Adrien Delorme
88116b1911 remove max_dl_operations setting
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
2025-04-24 11:39:42 +02:00
Adrien Delorme
f9af08820b perf(pull): multipart layer fetch
Signed-off-by: Adrien Delorme <azr@users.noreply.github.com>
Co-Authored-By: Corentin REGAL <143578+co42@users.noreply.github.com>
2025-04-24 11:39:42 +02:00
Tony Fang
b694be29a0 Update CRI image service to pull using transfer service
- adds a transfer service progress reporter to handle timeouts. Also other test fixes
- fallback to local image pull when configuration conflict

Signed-off-by: Tony Fang <nhfang@amazon.com>

Co-authored-by: Swagat Bora <sbora@amazon.com>
2025-04-23 18:18:27 +00:00
Iceber Gu
b8649bd38c client: fix returned error in the defer function
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2025-04-18 10:02:05 +08:00
Akihiro Suda
d9c889568e Remove the support for Schema 1 images
Schema 1 (`application/vnd.docker.distribution.manifest.v1+prettyjws`) has been
officially deprecated since containerd v1.7 (PR 6884), and disabled since v2.0 (PR 9765).

Users who have been seeing warnings like `conversion from schema 1 images is deprecated`
now have to rebuild the image with Schema 2 or OCI.

Schema 2 was introduced in Docker 1.10 (Feb 2016), so most users should have been already
using Schema 2 or OCI.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-11 09:03:26 +09:00
Iceber Gu
ec3567d6b3 update taskOptions based on runtimeOptions when creating a task
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2025-03-26 14:58:34 +08:00
Phil Estes
92885b1523 Merge pull request #11508 from vvoland/client-timeout-dialer
client: Respect `client.WithTimeout` option
2025-03-13 15:52:47 +00:00
Paweł Gronowski
8bc62da9c0 client/New: Don't unlazy the gRPC connection implicitly
When moving to gRPC 1.64 (commit 63b4688175) the usage of the deprecated
`grpc.DialContext` was replaced with `grpc.NewClient`. However, this
change also required to drop the `WithBlock` option, which made sure
that the connection is actually established before returning.

Now, `grpc.NewClient` doesn't attempt to perform the connection but
defers it to the actual first RPC.

Querying the default runtime on client creation breaks that property
depending on whether the default namespace is set or not.

This commit defers the `runtime` field initialization to the first time
the field is actually needed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-11 13:47:30 +01:00
Adrian Reber
9e6beafd53 Support container restore through CRI/Kubernetes
This implements container restore as described in:

https://kubernetes.io/blog/2022/12/05/forensic-container-checkpointing-alpha/#restore-checkpointed-container-standalone

For detailed step by step instruction also see contrib/checkpoint/checkpoint-restore-cri-test.sh

The code changes are based on changes I have done in Podman around 2018
and CRI-O around 2020.

The history behind restoring container via CRI/Kubernetes probably
requires some explanation. The initial proposal to bring
checkpoint/restore to Kubernetes was looking at pod checkpoint and
restoring and the corresponding CRI changes.

https://github.com/kubernetes-sigs/cri-tools/pull/662
https://github.com/kubernetes/kubernetes/pull/97194

After discussing this topic for about two years another approach was
implemented as described in KEP-2008:

https://github.com/kubernetes/enhancements/issues/2008

"Forensic Container Checkpointing" allowed us to separate checkpointing
from restoring. For the "Forensic Container Checkpointing" it is enough
to create a checkpoint of the container. Restoring is not necessary as
the analysis of the checkpoint archive can happen without restoring the
container.

While thinking about a way to restore a container it was by coincidence
that we started to look into restoring containers in Kubernetes via
Create and Start. The way it was done in CRI-O is to figure out during
Create if the container image is a checkpoint image and if that is true
we are using another code path. The same was implemented now with this
change in containerd.

With this change it is possible to restore the container from a
checkpoint tar archive that is created during checkpointing via CRI.

To restore a container via Kubernetes we convert the tar archive to an
OCI image as described in the kubernetes.io blog post from above. Using
this OCI image it is possible to restore a container in Kubernetes.

At this point I think it should be doable to restore containers in
CRI-O and containerd no matter if they have been created by containerd or
CRI-O. The biggest difference is the container metadata and that can
be adapted during restore.

Open items:

 * It is not clear to me why restoring a container in containerd goes
   through task/Create(). But as the restore code already exists this
   change extended the existing code path to restore a container in
   task/Create() to also restore a container through the CRI via
   Create and Start.
 * Automatic image pulling. containerd does not pull images
   automatically if created via the CRI. There is an option in
   crictl to pull images before starting, but that uses the CRI
   image pull interface. It is still a separate pull and create
   operation. Restoring containers from an OCI image is a bit
   different. The checkpoint OCI image does not include the base
   image, but just a reference to the image (NAME@DIGEST).
   Using crictl with pulling will enable the pulling of the
   checkpoint image, but not of the base image the checkpoint is
   based on. So during preparation of the checkpoint containerd
   will automatically pull the base image, but I was not able how
   to pull an image blockingly in containerd. So there is a for
   loop waiting for the container image to appear in the internal
   store. I think this probably can be implemented better.

Anyway, this is a first step towards container restored in Kubernetes
when using containerd.

Signed-off-by: Adrian Reber <areber@redhat.com>
2025-03-11 12:55:13 +01:00
Paweł Gronowski
ee574e76e7 client: Respect client.WithTimeout option
Fix the gRPC client dialer not using the timeout passed by the
containerd client timeout option.

Commit 63b4688175 replaced the usage of deprecated `grpc.DialContext`
with `grpc.NewClient`.

However, the `dialer.ContextDialer` relied on the context deadline to
propagate the timeout:

388fb336b0/vendor/google.golang.org/grpc/clientconn.go (L216)

This assumption is now broken, because `grpc.NewClient` doesn't do any
initial connection and defers it to the first RPC usage.

This commit passes the timeout via the `MinConnectTimeout` grpc
connection param, which will be applied to **every** connection attempt
(not just the first).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 16:42:04 +01:00
Sebastiaan van Stijn
a6dc9905cb client: add WithExtraDialOpts option
the client package provides a WithDialOpts option, however, dial-options
passed to override all defaults that are set in containerd. This makes it
difficult to expand the defaults with custom options, as this requires
copying the defaults, and trying to keep those in sync (e.g. see [moby#48617]).

This patch introduces a new `WithExtraDialOpts` option which, unlike
`WithDialOpts` are appended to, instead of overriding, previous options.
This allows setting custom options, while maintaining containerd's defaults.

Also unlike `WithDialOpts`, this option can be used multiple times to allow
additional options to be set.

[moby#48617]: https://github.com/moby/moby/pull/48617

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 16:18:59 +01:00
Phil Estes
98af40b752 Merge pull request #10722 from henry118/uidmap2
Support multiple uid/gid mappings [2/2]
2025-01-17 18:34:40 +00:00
Kazuyoshi Kato
5ad6a150b6 Merge pull request #11189 from djdongjin/move-to-go-native-fuzz
Move fuzz tests to go native fuzz [part1]
2025-01-10 01:27:14 +00:00
Jin Dong
a550830078 Remove github.com/AdamKorcz/go-118-fuzz-build in go.mod
We can add the dependency in oss_fuzz_build.sh, since
it's only used for oss-fuzz

change os.MkdirTemp to t.TempDir in fuzz tests

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2024-12-25 01:25:48 +00:00
Austin Vazquez
bee64b2b93 Remove loop variable copies
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-12-23 23:14:49 -07:00
Henry Wang
8bbfb65289 Update snapshotter opts to support multiple uid/gid mapping entries
Signed-off-by: Henry Wang <henwang@amazon.com>
2024-12-11 18:04:11 +00:00
Derek McGowan
2f24aa00a5 Update errdefs to 0.3.0
Uses the new github.com/containerd/errdefs/pkg module which is intended
to hold less stable utility functions separately from the stable
github.com/containerd/errdefs error types.

Includes temporary update to hcsshim until a release is cut there

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-18 16:04:54 -07:00
Abel Feng
fc5086a74d cri: remove sandbox controller from client
cri will call sandbox controller from the sandboxService, remove the
dependency of client.

Signed-off-by: Abel Feng <fshb1988@gmail.com>
2024-10-16 17:37:07 +08:00
Abel Feng
e4df672ab8 sandbox: add sandbox controller v2
Signed-off-by: Abel Feng <fshb1988@gmail.com>
2024-10-16 17:37:05 +08:00
Henry Wang
83aaa89b61 update ctr run to support multiple uid/gid mappings
Signed-off-by: Henry Wang <henwang@amazon.com>
2024-09-10 17:06:27 +00:00
Swagat Bora
c0cdcb34f1 Add spans to CRI runtime service and related client methods
This adds otel spans to CRI service mainly targeting mutating apis which includes:
* Sandbox apis - RunPodSandbox, StopPodSandbox, RemovePodSandbox
* Container apis - CreateContainer, StartContainer, StopContainer, RemoveContainer
* Attach, Exec and Exec Sync
* Containerd client methods: container.go, client.go, process.go and task.go

Signed-off-by: Swagat Bora <sbora@amazon.com>
2024-08-05 02:34:20 +00:00
Maksym Pavlenko
fd2a7676a3 Merge pull request #10442 from Iceber/fix_ctr_delete_force
client: fix tasks with PID 0 cannot be forced to delete
2024-07-30 20:14:08 +00:00
Samuel Karp
1e3c35bd0d Merge pull request #10488 from dcantah/avoid-realloc
Avoid potential reallocs by pre-sizing some slices
2024-07-22 05:39:19 +00:00
Danny Canter
b41bb6df73 Avoid potential reallocs by pre-sizing some slices
There's a couple spots where we know exactly how large
the destination buffer should be, so pre-size these to
avoid any reallocs to a higher capacity.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2024-07-19 13:05:49 -07:00
Maksym Pavlenko
fb674f8b48 Add resolver workaround for error: name resolver error: produced zero addresses
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2024-07-18 15:26:02 -07:00
Maksym Pavlenko
63b4688175 Use grpc.NewClient instead of deprecated ones
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2024-07-18 15:26:02 -07:00
Akhil Mohan
300fd770a0 use typeurl funcs for marshalling anypb.Any
Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
2024-07-10 22:26:27 +05:30
Iceber Gu
efd4415062 client: fix tasks with PID 0 cannot be forced to delete
Signed-off-by: Iceber Gu <caiwei95@hotmail.com>
2024-07-08 17:24:58 +08:00
Abel Feng
15887d7efc sandbox: add update api for controller
Signed-off-by: Abel Feng <fshb1988@gmail.com>
2024-06-14 02:31:51 +00:00
Abel Feng
678137199a sandbox: remove PID() in sandbox client
which is not used and for some sandbox implementation, we may not get
the pid of a sandbox.

Signed-off-by: Abel Feng <fshb1988@gmail.com>
2024-05-07 00:51:33 +08:00
Derek McGowan
05a3171bb4 Update transfer proxy to support ttrpc
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-02 23:16:51 -07:00
Derek McGowan
ec04e4f638 Add streaming proxy
Signed-off-by: Derek McGowan <derek@mcg.dev>

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-02 22:38:14 -07:00
Derek McGowan
2ac2b9c909 Make api a Go sub-module
Allow the api to stay at the same v1 go package name and keep using a
1.x version number. This indicates the API is still at 1.x and allows
sharing proto types with containerd 1.6 and 1.7 releases.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-02 11:03:00 -07:00
Derek McGowan
e1b94c0e7d Move protobuf package under pkg
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-02 10:52:03 -07:00
Derek McGowan
4a45507772 Move runc options to api directory
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-02 10:52:00 -07:00
Fu Wei
a91b05d99c Merge pull request #9736 from abel-von/sandbox-task-0201
sandbox: Store bootstrap parameters in sandbox metadata and shim get them from sandbox metadata rather than other shim's bootstrap.json file.
2024-05-02 15:35:29 +00:00