Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for checkpoint/restore of containers with volumes #8781

Merged
merged 4 commits into from
Jan 8, 2021

Conversation

rst0git
Copy link
Contributor

@rst0git rst0git commented Dec 18, 2020

When migrating a container with volumes, the content of the volumes is required to be available on the destination machine.

This PR enables checkpoint/restore of containers with named volumes by including the content of volumes in checkpoint file. When restoring a container, the associated volumes are recreated and their content is restored accordingly.

In addition, this PR adds --ignore-volumes option to disable this feature.

Examples:

In the following example the content of associated volumes is included in checkpoint tar.gz file.

# podman container checkpoint --export <checkpoint>.tar.gz <container>

This example doesn't include the content of volumes in the tar.gz file. This can be used to avoid unnecessary I/O operations when running checkpoint and restore on the same host.

# podman container checkpoint --ignore-volumes --export <checkpoint>.tar.gz <container>

In the following example the container volumes will be recreated and their content restored. Note that if volumes with the same name already exist on the system, or the content of volumes is missing in the tar.gz, Podman will exit with an error.

# podman container restore --import <checkpoint>.tar.gz

Volumes associated with container must already exist. Podman will not create them or to restore their content.

# podman container restore --ignore-volumes --import <checkpoint>.tar.gz

Resolves checkpoint-restore/criu#1314 checkpoint-restore/criu#826

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 18, 2020
@rst0git
Copy link
Contributor Author

rst0git commented Dec 18, 2020

cc @adrianreber

@adrianreber
Copy link
Collaborator

@rstgit Thanks a lot. Looks correct. You should probably add a test for this.

In the output of '--help' you also just talk about 'volumes'. Not sure if we need to mention 'named volumes' at those places.

What about the shell completion files? Are they automatically created or do they also need updating?

@rst0git
Copy link
Contributor Author

rst0git commented Dec 29, 2020

Hi @adrianreber,

You should probably add a test for this.

I've updated the PR to include a test case.

In the output of '--help' you also just talk about 'volumes'. Not sure if we need to mention 'named volumes' at those places.

Thank you for pointing this out, I should have made it clearer. The initial goal was to extend the checkpoint/restore functionality with support for containers such as 'mysql' that use the VOLUME instruction. This instruction creates a volume with specified name that must be unique on the host. However, such volumes are also described in the documentation as "anonymously named" because they have randomly generated name and will be removed when the container is removed. In addition, when volumes are created with names they are not anonymous, and they are not removed by the --rm option.

The changes in this PR extend Podman to be able to checkpoint/restore named, anonymously named, and anonymous volumes.

To avoid unnecessary confusion, I used only the word "volumes" in the output of --help, but I'm open to suggestions that would make it easier to understand.

What about the shell completion files? Are they automatically created or do they also need updating?

Yes, the shell completions appear to process the output of --help, hence they are updated automatically.

@rst0git rst0git force-pushed the cr-volumes branch 4 times, most recently from 6ddbc98 to d397c7a Compare December 29, 2020 10:30
@rst0git rst0git marked this pull request as ready for review December 29, 2020 16:00
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 29, 2020
Instead of individual values from ContainerCheckpointOptions,
provide the options object.

This is a preparation for the next patch where one more value
of the options object is required in exportCheckpoint().

Signed-off-by: Radostin Stoyanov <[email protected]>
Instead of specifying restore option arguments individually from
RestoreOptions, provide the 'options' object to the CRImportCheckpoint
method. This change makes the code in CRImportCheckpoint easier to
extend as it doesn't require excessive number of function parameters.

Signed-off-by: Radostin Stoyanov <[email protected]>
When migrating a container with associated volumes, the content of
these volumes should be made available on the destination machine.

This patch enables container checkpoint/restore with named volumes
by including the content of volumes in checkpoint file. On restore,
volumes associated with container are created and their content is
restored.

The --ignore-volumes option is introduced to disable this feature.

Example:

 # podman container checkpoint --export checkpoint.tar.gz <container>

The content of all volumes associated with the container are included
in `checkpoint.tar.gz`

 # podman container checkpoint --export checkpoint.tar.gz --ignore-volumes <container>

The content of volumes is not included in `checkpoint.tar.gz`. This is
useful, for example, when the checkpoint/restore is performed on the
same machine.

 # podman container restore --import checkpoint.tar.gz

The associated volumes will be created and their content will be
restored. Podman will exit with an error if volumes with the same
name already exist on the system or the content of volumes is not
included in checkpoint.tar.gz

 # podman container restore --ignore-volumes --import checkpoint.tar.gz

Volumes associated with container must already exist. Podman will not
create them or restore their content.

Signed-off-by: Radostin Stoyanov <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jan 7, 2021

@adrianreber PTAL

@adrianreber
Copy link
Collaborator

Looks good. Thanks!

@mheon
Copy link
Member

mheon commented Jan 8, 2021

LGTM

@mheon
Copy link
Member

mheon commented Jan 8, 2021

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon, rst0git

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 8, 2021
@rhatdan
Copy link
Member

rhatdan commented Jan 8, 2021

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 8, 2021
@openshift-merge-robot openshift-merge-robot merged commit 49db79e into containers:master Jan 8, 2021
rst0git added a commit to rst0git/checkpointctl that referenced this pull request Mar 18, 2022
The "volumes" directory was introduced in Podman with [1].  It is used
to store the content of volumes associates with checkpointed container.

[1] containers/podman#8781

Signed-off-by: Radostin Stoyanov <[email protected]>
@rst0git rst0git deleted the cr-volumes branch January 11, 2023 15:22
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Criu checkpoint a container with SELinux and --tmpfs
7 participants