Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ checkpointed.`,
cli.StringFlag{Name: "page-server", Value: "", Usage: "ADDRESS:PORT of the page server"},
cli.BoolFlag{Name: "file-locks", Usage: "handle file locks, for safety"},
cli.BoolFlag{Name: "pre-dump", Usage: "dump container's memory information only, leave the container running after this"},
cli.StringFlag{Name: "manage-cgroups-mode", Value: "", Usage: "cgroups mode: 'soft' (default), 'full' and 'strict'"},
cli.StringFlag{Name: "manage-cgroups-mode", Value: "", Usage: "cgroups mode: 'soft' (default), 'ignore', 'full' and 'strict'"},
cli.StringSliceFlag{Name: "empty-ns", Usage: "create a namespace, but don't restore its properties"},
cli.BoolFlag{Name: "auto-dedup", Usage: "enable auto deduplication of memory images"},
},
Expand Down Expand Up @@ -147,6 +147,8 @@ func setManageCgroupsMode(context *cli.Context, options *libcontainer.CriuOpts)
options.ManageCgroupsMode = criu.CriuCgMode_FULL
case "strict":
options.ManageCgroupsMode = criu.CriuCgMode_STRICT
case "ignore":
options.ManageCgroupsMode = criu.CriuCgMode_IGNORE
default:
return errors.New("Invalid manage cgroups mode")
}
Expand Down
2 changes: 1 addition & 1 deletion man/runc-checkpoint.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ together with **criu lazy-pages**. See
: Do a pre-dump, i.e. dump container's memory information only, leaving the
container running. See [criu iterative migration](https://criu.org/Iterative_migration).

**--manage-cgroups-mode** **soft**|**full**|**strict**.
**--manage-cgroups-mode** **soft**|**ignore**|**full**|**strict**.
: Cgroups mode. Default is **soft**. See
[criu --manage-cgroups option](https://criu.org/CLI/opt/--manage-cgroups).

Expand Down
2 changes: 1 addition & 1 deletion man/runc-restore.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ image files directory.
: Allow checkpoint/restore of file locks. See
[criu --file-locks option](https://criu.org/CLI/opt/--file-locks).

**--manage-cgroups-mode** **soft**|**full**|**strict**.
**--manage-cgroups-mode** **soft**|**ignore**|**full**|**strict**.
: Cgroups mode. Default is **soft**. See
[criu --manage-cgroups option](https://criu.org/CLI/opt/--manage-cgroups).

Expand Down
5 changes: 4 additions & 1 deletion restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using the runc checkpoint command.`,
cli.StringFlag{
Name: "manage-cgroups-mode",
Value: "",
Usage: "cgroups mode: 'soft' (default), 'full' and 'strict'",
Usage: "cgroups mode: 'soft' (default), 'ignore', 'full' and 'strict'",
},
cli.StringFlag{
Name: "bundle, b",
Expand Down Expand Up @@ -116,6 +116,9 @@ using the runc checkpoint command.`,
if err := setEmptyNsMask(context, options); err != nil {
return err
}
if err := setManageCgroupsMode(context, options); err != nil {
return err
}
status, err := startContainer(context, CT_ACT_RESTORE, options)
if err != nil {
return err
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,40 @@ function simple_cr() {
# busybox should be back up and running
testcontainer test_busybox running
}

@test "checkpoint and restore into a different cgroup" {
local pid name=test-diff-cgroup

set_cgroups_path
runc run -d --console-socket "$CONSOLE_SOCKET" --pid-file pid "$name"
[ "$status" -eq 0 ]

testcontainer "$name" running
# Check the cgroup.
pid="$(cat pid)"
original_cgroup="$OCI_CGROUPS_PATH"
echo "OCI_CGROUPS_PATH=$OCI_CGROUPS_PATH"
cat "/proc/$pid/cgroup"

runc checkpoint --manage-cgroups-mode ignore --work-path ./work-dir "$name"
grep -B 5 Error ./work-dir/dump.log || true
[ "$status" -eq 0 ]

testcontainer "$name" checkpointed

# Modify the cgroup path.
set_cgroups_path
runc restore --manage-cgroups-mode ignore --pid-file pid -d \
--work-path ./work-dir --console-socket "$CONSOLE_SOCKET" "$name"
grep -B 5 Error ./work-dir/restore.log || true
[ "$status" -eq 0 ]

testcontainer "$name" running

# Check the cgroup name has changed.
pid="$(cat pid)"
echo "OCI_CGROUPS_PATH=$OCI_CGROUPS_PATH"
cat "/proc/$pid/cgroup"
new_cgroup="$OCI_CGROUPS_PATH"
[ "$original_cgroup" != "$new_cgroup" ]
}
11 changes: 10 additions & 1 deletion tests/rootless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,16 @@ function disable_cgroup() {
[ -d "$CGROUP_MOUNT/$cg$CGROUP_PATH" ] && rmdir "$CGROUP_MOUNT/$cg$CGROUP_PATH"
done
# cgroup v2
[ -d "$CGROUP_MOUNT/$CGROUP_PATH" ] && rmdir "$CGROUP_MOUNT/$CGROUP_PATH"
if [ -d "$CGROUP_MOUNT$CGROUP_PATH" ]; then
if ! rmdir "$CGROUP_MOUNT$CGROUP_PATH"; then
echo "ERROR: could not remove $CGROUP_MOUNT$CGROUP_PATH"
ls -lR "$CGROUP_MOUNT$CGROUP_PATH"
for pid in $(find "$CGROUP_MOUNT$CGROUP_PATH" -name cgroup.procs -exec cat '{}' +); do
ps -c $pid
done
return 1
fi
fi

return 0
}
Expand Down