Commit Graph
8 Commits
Author SHA1 Message Date
Samuel Karp 91be73ba62 cri: remove restore in CreateContainer
Remove support for restoring checkpoint data during CreateContainer,
which was previously deprecated in v2.3.

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-07-29 09:32:24 -07:00
Samuel Karp a3f99ba690 cri: deprecate restore in CreateContainer
Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-07-27 22:11:29 -07:00
Samuel Karp 06495733b2 cri: add enable_criu configuration option
Add a new `enable_criu` configuration option under CRI plugin runtime
settings. When set to false, any checkpoint or restore request will fail
fast with an error indicating that CRIU support is disabled by
configuration. `enable_criu` currently defaults to true.

Add an integration test script to verify that setting `enable_criu` to
false in containerd configuration successfully disables checkpoint and
restore operations and fails fast.

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-06-30 12:47:48 -07:00
Chris Henzie a0086cfcee Merge commit from fork 2026-06-15 21:26:29 -07:00
Samuel Karp 861ffc1097 cri: filter CDI annotations on checkpoint restore
Filter out any annotations on the checkpointed container matching
`cdi.k8s.io/` or exactly `cdi.k8s.io` during restore to prevent
unauthorized device restoration. When an annotation is denied, a warning
log is generated.

Tested by:
* Unit tests for exact matching, prefix boundaries, and metadata merging
* Complete CRI integration and checkpoint restore suite

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-06-09 16:56:45 -07:00
Samuel Karp 0c0918fa8f cri: do not re-tag restored checkpoints
Google-Bug-Id: 508657842
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-06-03 10:49:45 -07:00
Samuel Karp 7515c32ea4 contrib/checkpoint: increase timeouts to 30s
Under slow network conditions (e.g., simulated 2 Mbps ingress bandwidth
limits in CI), restoring a container from a checkpoint can fail if it
requires pulling the base image again.

During restore, crictl create is called. In test_from_oci, it used a
10-second timeout (crictl -t 10s create). Over a 2 Mbps connection,
pulling the 2.8MB Alpine layer takes ~12-13 seconds, causing the
operation to exceed the timeout and fail with context canceled.

Increase the timeouts in both test_from_archive and test_from_oci to
30 seconds. This ensures the base image pull can complete successfully
even in constrained CI environments.

Tested:
Ran the CRI integration tests on a GCE VM under a simulated 2 Mbps
ingress bandwidth limit using traffic control (tc). Verified that
both test_from_archive and test_from_oci passed successfully and
container restore completed without timeout.

Assisted-by: Antigravity
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2026-05-19 15:59:31 -07: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