Skip to content

Commit

Permalink
Pass '--file-locks' to OCI runtime at restoring
Browse files Browse the repository at this point in the history
`podman container restore --file-locks` does not restore file locks
because this option is not passed to OCI runtime. This patch fixes this
issue.

Signed-off-by: Hironori Shiina <[email protected]>
  • Loading branch information
Hironori Shiina authored and mheon committed Jun 14, 2022
1 parent f15819f commit 8ed9aab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/domain/infra/abi/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func (ic *ContainerEngine) ContainerRestore(ctx context.Context, namesOrIds []st
ImportPrevious: options.ImportPrevious,
Pod: options.Pod,
PrintStats: options.PrintStats,
FileLocks: options.FileLocks,
}

filterFuncs := []libpod.ContainerFilter{
Expand Down
30 changes: 30 additions & 0 deletions test/system/520-checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,34 @@ function teardown() {

# FIXME: test --leave-running

@test "podman checkpoint --file-locks" {
action='flock test.lock sh -c "while [ -e /wait ];do sleep 0.5;done;for i in 1 2 3;do echo \$i;sleep 0.5;done"'
run_podman run -d $IMAGE sh -c "touch /wait; touch test.lock; echo READY; $action & $action & wait"
local cid="$output"

# Wait for container to start emitting output
wait_for_ready $cid

# Checkpoint, and confirm via inspect
run_podman container checkpoint --file-locks $cid
is "$output" "$cid" "podman container checkpoint"

run_podman container inspect \
--format '{{.State.Status}}:{{.State.Running}}:{{.State.Paused}}:{{.State.Checkpointed}}' $cid
is "$output" "exited:false:false:true" "State. Status:Running:Pause:Checkpointed"

# Restart immediately and confirm state
run_podman container restore --file-locks $cid
is "$output" "$cid" "podman container restore"

# Signal the container to continue; this is where the 1-2-3s will come from
run_podman exec $cid rm /wait

# Wait for the container to stop
run_podman wait $cid

run_podman logs $cid
trim=$(sed -z -e 's/[\r\n]\+//g' <<<"$output")
is "$trim" "READY123123" "File lock restored"
}
# vim: filetype=sh

0 comments on commit 8ed9aab

Please sign in to comment.