merge branch 'pr-2509'
Kir Kolyshkin (2): tests/int/checkpoint: fds and pids cleanup tests/int/checkpoint: don't remove readonly flag LGTMs: @mrunalp @AkihiroSuda @cyphar Closes #2509
This commit is contained in:
commit
f8749ba098
|
@ -12,6 +12,17 @@ function setup() {
|
||||||
|
|
||||||
function teardown() {
|
function teardown() {
|
||||||
teardown_busybox
|
teardown_busybox
|
||||||
|
local pid fd
|
||||||
|
|
||||||
|
for pid in "${PIDS_TO_KILL[@]}"; do
|
||||||
|
kill -9 $pid || true
|
||||||
|
done
|
||||||
|
PIDS_TO_KILL=()
|
||||||
|
|
||||||
|
for fd in "${FDS_TO_CLOSE[@]}"; do
|
||||||
|
exec {fd}>&-
|
||||||
|
done
|
||||||
|
FDS_TO_CLOSE=()
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_pipes() {
|
function setup_pipes() {
|
||||||
|
@ -21,22 +32,23 @@ function setup_pipes() {
|
||||||
|
|
||||||
# Create two sets of pipes
|
# Create two sets of pipes
|
||||||
# for stdout/stderr
|
# for stdout/stderr
|
||||||
exec 52<> <(:)
|
exec {pipe}<> <(:)
|
||||||
exec 50</proc/self/fd/52
|
exec {out_r}</proc/self/fd/$pipe
|
||||||
exec 51>/proc/self/fd/52
|
exec {out_w}>/proc/self/fd/$pipe
|
||||||
exec 52>&-
|
exec {pipe}>&-
|
||||||
# ... and stdin
|
# ... and stdin
|
||||||
exec 62<> <(:)
|
exec {pipe}<> <(:)
|
||||||
exec 60</proc/self/fd/62
|
exec {in_r}</proc/self/fd/$pipe
|
||||||
exec 61>/proc/self/fd/62
|
exec {in_w}>/proc/self/fd/$pipe
|
||||||
exec 62>&-
|
exec {pipe}>&-
|
||||||
|
FDS_TO_CLOSE=($in_r $in_w $out_r $out_w)
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_pipes() {
|
function check_pipes() {
|
||||||
echo Ping >&61
|
echo Ping >&${in_w}
|
||||||
exec 61>&-
|
exec {in_w}>&-
|
||||||
exec 51>&-
|
exec {out_w}>&-
|
||||||
run cat <&50
|
run cat <&${out_r}
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "${output}" == *"ponG Ping"* ]]
|
[[ "${output}" == *"ponG Ping"* ]]
|
||||||
}
|
}
|
||||||
|
@ -84,7 +96,7 @@ function simple_cr() {
|
||||||
setup_pipes
|
setup_pipes
|
||||||
|
|
||||||
# run busybox
|
# run busybox
|
||||||
__runc run -d test_busybox <&60 >&51 2>&51
|
__runc run -d test_busybox <&${in_r} >&${out_w} 2>&${out_w}
|
||||||
[ $? -eq 0 ]
|
[ $? -eq 0 ]
|
||||||
|
|
||||||
testcontainer test_busybox running
|
testcontainer test_busybox running
|
||||||
|
@ -108,7 +120,7 @@ function simple_cr() {
|
||||||
testcontainer test_busybox checkpointed
|
testcontainer test_busybox checkpointed
|
||||||
|
|
||||||
# restore from checkpoint
|
# restore from checkpoint
|
||||||
__runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&60 >&51 2>&51
|
__runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&${in_r} >&${out_w} 2>&${out_w}
|
||||||
ret=$?
|
ret=$?
|
||||||
cat ./work-dir/restore.log | grep -B 5 Error || true
|
cat ./work-dir/restore.log | grep -B 5 Error || true
|
||||||
[ $ret -eq 0 ]
|
[ $ret -eq 0 ]
|
||||||
|
@ -132,14 +144,11 @@ function simple_cr() {
|
||||||
|
|
||||||
setup_pipes
|
setup_pipes
|
||||||
|
|
||||||
# This should not be necessary: https://github.com/checkpoint-restore/criu/issues/575
|
|
||||||
update_config '(.. | select(.readonly? != null)) .readonly |= false'
|
|
||||||
|
|
||||||
# TCP port for lazy migration
|
# TCP port for lazy migration
|
||||||
port=27277
|
port=27277
|
||||||
|
|
||||||
# run busybox
|
# run busybox
|
||||||
__runc run -d test_busybox <&60 >&51 2>&51
|
__runc run -d test_busybox <&${in_r} >&${out_w} 2>&${out_w}
|
||||||
[ $? -eq 0 ]
|
[ $? -eq 0 ]
|
||||||
|
|
||||||
testcontainer test_busybox running
|
testcontainer test_busybox running
|
||||||
|
@ -150,16 +159,18 @@ function simple_cr() {
|
||||||
|
|
||||||
# For lazy migration we need to know when CRIU is ready to serve
|
# For lazy migration we need to know when CRIU is ready to serve
|
||||||
# the memory pages via TCP.
|
# the memory pages via TCP.
|
||||||
exec 72<> <(:)
|
exec {pipe}<> <(:)
|
||||||
exec 70</proc/self/fd/72 71>/proc/self/fd/72
|
exec {lazy_r}</proc/self/fd/$pipe {lazy_w}>/proc/self/fd/$pipe
|
||||||
exec 72>&-
|
exec {pipe}>&-
|
||||||
|
FDS_TO_CLOSE+=($lazy_r $lazy_w)
|
||||||
|
|
||||||
__runc --criu "$CRIU" checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd 71 --work-path ./work-dir --image-path ./image-dir test_busybox &
|
__runc --criu "$CRIU" checkpoint --lazy-pages --page-server 0.0.0.0:${port} --status-fd ${lazy_w} --work-path ./work-dir --image-path ./image-dir test_busybox &
|
||||||
cpt_pid=$!
|
cpt_pid=$!
|
||||||
|
PIDS_TO_KILL=($cpt_pid)
|
||||||
|
|
||||||
# wait for lazy page server to be ready
|
# wait for lazy page server to be ready
|
||||||
out=$(timeout 2 dd if=/proc/self/fd/70 bs=1 count=1 2>/dev/null | od)
|
out=$(timeout 2 dd if=/proc/self/fd/${lazy_r} bs=1 count=1 2>/dev/null | od)
|
||||||
exec 71>&-
|
exec {lazy_w}>&-
|
||||||
out=$(echo $out) # rm newlines
|
out=$(echo $out) # rm newlines
|
||||||
# show errors if there are any before we fail
|
# show errors if there are any before we fail
|
||||||
grep -B5 Error ./work-dir/dump.log || true
|
grep -B5 Error ./work-dir/dump.log || true
|
||||||
|
@ -172,6 +183,7 @@ function simple_cr() {
|
||||||
# Start CRIU in lazy-daemon mode
|
# Start CRIU in lazy-daemon mode
|
||||||
${CRIU} lazy-pages --page-server --address 127.0.0.1 --port ${port} -D image-dir &
|
${CRIU} lazy-pages --page-server --address 127.0.0.1 --port ${port} -D image-dir &
|
||||||
lp_pid=$!
|
lp_pid=$!
|
||||||
|
PIDS_TO_KILL+=($lp_pid)
|
||||||
|
|
||||||
# Restore lazily from checkpoint.
|
# Restore lazily from checkpoint.
|
||||||
# The restored container needs a different name as the checkpointed
|
# The restored container needs a different name as the checkpointed
|
||||||
|
@ -179,7 +191,7 @@ function simple_cr() {
|
||||||
# in time when the last page is lazily transferred to the destination.
|
# in time when the last page is lazily transferred to the destination.
|
||||||
# Killing the CRIU on the checkpoint side will let the container
|
# Killing the CRIU on the checkpoint side will let the container
|
||||||
# continue to run if the migration failed at some point.
|
# continue to run if the migration failed at some point.
|
||||||
__runc --criu "$CRIU" restore -d --work-path ./image-dir --image-path ./image-dir --lazy-pages test_busybox_restore <&60 >&51 2>&51
|
__runc --criu "$CRIU" restore -d --work-path ./image-dir --image-path ./image-dir --lazy-pages test_busybox_restore <&${in_r} >&${out_w} 2>&${out_w}
|
||||||
ret=$?
|
ret=$?
|
||||||
cat ./work-dir/restore.log | grep -B 5 Error || true
|
cat ./work-dir/restore.log | grep -B 5 Error || true
|
||||||
[ $ret -eq 0 ]
|
[ $ret -eq 0 ]
|
||||||
|
@ -196,6 +208,7 @@ function simple_cr() {
|
||||||
|
|
||||||
wait $lp_pid
|
wait $lp_pid
|
||||||
[ $? -eq 0 ]
|
[ $? -eq 0 ]
|
||||||
|
PIDS_TO_KILL=()
|
||||||
|
|
||||||
check_pipes
|
check_pipes
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue