-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
cc @adrianreber |
@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? |
Hi @adrianreber,
I've updated the PR to include a test case.
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 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
Yes, the shell completions appear to process the output of |
6ddbc98
to
d397c7a
Compare
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]>
Signed-off-by: Radostin Stoyanov <[email protected]>
@adrianreber PTAL |
Looks good. Thanks! |
LGTM |
/approve |
[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 |
/lgtm |
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]>
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