-
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
sys tests: run_podman: check for unwanted warnings/errors #19878
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,7 +181,7 @@ echo $rand | 0 | $rand | |
run_podman image exists $NONLOCAL_IMAGE | ||
|
||
# Now try running with --rmi : it should succeed, but not remove the image | ||
run_podman run --rmi --rm $NONLOCAL_IMAGE /bin/true | ||
run_podman 0+e run --rmi --rm $NONLOCAL_IMAGE /bin/true | ||
is "$output" ".*image is in use by a container" "--rmi should warn that the image was not removed" | ||
run_podman image exists $NONLOCAL_IMAGE | ||
|
||
|
@@ -229,7 +229,7 @@ echo $rand | 0 | $rand | |
"conmon pidfile (= PID $conmon_pid_from_file) points to conmon process" | ||
|
||
# All OK. Kill container. | ||
run_podman rm -f $cid | ||
run_podman rm -f -t0 $cid | ||
if [[ -e $cidfile ]]; then | ||
die "cidfile $cidfile should be removed along with container" | ||
fi | ||
|
@@ -946,7 +946,7 @@ EOF | |
if grep -- -1000 /proc/self/oom_score_adj; then | ||
skip "the current oom-score-adj is already -1000" | ||
fi | ||
run_podman run --oom-score-adj=-1000 --rm $IMAGE true | ||
run_podman 0+w run --oom-score-adj=-1000 --rm $IMAGE true | ||
is "$output" ".*Requested oom_score_adj=.* is lower than the current one, changing to .*" | ||
} | ||
|
||
|
@@ -1058,7 +1058,12 @@ $IMAGE--c_ok" \ | |
"ls /dev/tty[0-9] with --systemd=always: should have no ttyN devices" | ||
|
||
# Make sure run_podman stop supports -1 option | ||
run_podman stop -t -1 $cid | ||
# FIXME: why is there no signal name here? Should be 'StopSignal XYZ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks like a fart. Especially the double white space screams for the value being printed to differ from the one actually being used. For instance, the value being an empty string as printed which is later on being normalized to SIGTERM. Likely needs a dedicated issue. |
||
# FIXME: do we really really mean to say FFFFFFFFFFFFFFFF here??? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand the question. Can you elaborate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I don't know the reasoning behind accepting |
||
run_podman 0+w stop -t -1 $cid | ||
if ! is_remote; then | ||
assert "$output" =~ "StopSignal failed to stop container .* in 18446744073709551615 seconds, resorting to SIGKILL" "stop -t -1 (negative one) issues warning" | ||
vrothberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
run_podman rm -t -1 -f $cid | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,10 @@ load helpers | |
run_podman wait $cid_none_implicit $cid_none_explicit $cid_on_failure | ||
|
||
run_podman rm $cid_none_implicit $cid_none_explicit $cid_on_failure | ||
run_podman stop -t 1 $cid_always | ||
run_podman 0+w stop -t 1 $cid_always | ||
if ! is_remote; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning is never seen in podman-remote. Should it be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally yes but it's technically very difficult. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack, thanks. |
||
assert "$output" =~ "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL" | ||
fi | ||
run_podman rm $cid_always | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,7 +222,7 @@ function teardown() { | |
local subnet="$(random_rfc1918_subnet)" | ||
run_podman network create --subnet "$subnet.0/24" $netname | ||
|
||
run_podman run -d --network $netname $IMAGE sleep inf | ||
run_podman run -d --network $netname $IMAGE top | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed all If there is some important reason for using |
||
cid="$output" | ||
# get current ip and mac | ||
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").IPAddress}}" | ||
|
@@ -310,7 +310,7 @@ function teardown() { | |
# now create a container with a static mac and ip | ||
local static_ip="$subnet.2" | ||
local static_mac="92:d0:c6:0a:29:38" | ||
run_podman run -d --network "$netname:ip=$static_ip,mac=$static_mac" $IMAGE sleep inf | ||
run_podman run -d --network "$netname:ip=$static_ip,mac=$static_mac" $IMAGE top | ||
cid="$output" | ||
|
||
run_podman container checkpoint $cid | ||
|
@@ -340,7 +340,7 @@ function teardown() { | |
run_podman rm -t 0 -f $cid | ||
|
||
# now create container again and try the same again with --export and --import | ||
run_podman run -d --network "$netname:ip=$static_ip,mac=$static_mac" $IMAGE sleep inf | ||
run_podman run -d --network "$netname:ip=$static_ip,mac=$static_mac" $IMAGE top | ||
cid="$output" | ||
|
||
run_podman container checkpoint --export "$archive" $cid | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,8 +325,11 @@ function timestamp() { | |
# | ||
function run_podman() { | ||
# Number as first argument = expected exit code; default 0 | ||
expected_rc=0 | ||
# "0+[we]" = require success, but allow warnings/errors | ||
local expected_rc=0 | ||
local allowed_levels="dit" | ||
case "$1" in | ||
0\+[we]*) allowed_levels+=$(expr "$1" : "^0+\([we]\+\)"); shift;; | ||
[0-9]) expected_rc=$1; shift;; | ||
[1-9][0-9]) expected_rc=$1; shift;; | ||
[12][0-9][0-9]) expected_rc=$1; shift;; | ||
|
@@ -336,8 +339,8 @@ function run_podman() { | |
# Remember command args, for possible use in later diagnostic messages | ||
MOST_RECENT_PODMAN_COMMAND="podman $*" | ||
|
||
# stdout is only emitted upon error; this echo is to help a debugger | ||
echo "$(timestamp) $_LOG_PROMPT $PODMAN $*" | ||
# stdout is only emitted upon error; this printf is to help in debugging | ||
printf "\n%s %s %s\n" "$(timestamp)" "$_LOG_PROMPT" "$*" | ||
Comment on lines
+342
to
+343
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is completely unrelated, I'm just sneaking it in. It adds an extra newline, which has greatly helped me scan error logs for most-recent-podman-command. |
||
# BATS hangs if a subprocess remains and keeps FD 3 open; this happens | ||
# if podman crashes unexpectedly without cleaning up subprocesses. | ||
run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN $_PODMAN_TEST_OPTS "$@" 3>/dev/null | ||
|
@@ -381,6 +384,28 @@ function run_podman() { | |
die "exit code is $status; expected $expected_rc" | ||
fi | ||
fi | ||
|
||
# Check for "level=<unexpected>" in output, because a successful command | ||
# should never issue unwanted warnings or errors. The "0+w" convention | ||
# (see top of function) allows our caller to indicate that warnings are | ||
# expected, e.g., "podman stop" without -t0. | ||
if [[ $status -eq 0 ]]; then | ||
# FIXME: don't do this on Debian: runc is way, way too flaky: | ||
# FIXME: #11784 - lstat /sys/fs/.../*.scope: ENOENT | ||
# FIXME: #11785 - cannot toggle freezer: cgroups not configured | ||
Comment on lines
+393
to
+395
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any way around this |
||
if [[ ! "${DISTRO_NV}" =~ debian ]]; then | ||
# FIXME: All kube commands emit unpredictable errors: | ||
# "Storage for container <X> has been removed" | ||
# "no container with ID <X> found in database" | ||
# These are level=error but we still get exit-status 0. | ||
# Just skip all kube commands completely | ||
Comment on lines
+397
to
+401
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, though, really bothers me. |
||
if [[ ! "$*" =~ kube ]]; then | ||
if [[ "$output" =~ level=[^${allowed_levels}] ]]; then | ||
die "Command succeeded, but issued unexpected warnings" | ||
fi | ||
fi | ||
fi | ||
fi | ||
} | ||
|
||
|
||
|
@@ -413,7 +438,7 @@ function wait_for_output { | |
|
||
t1=$(expr $SECONDS + $how_long) | ||
while [ $SECONDS -lt $t1 ]; do | ||
run_podman logs $cid | ||
run_podman 0+w logs $cid | ||
logs=$output | ||
if expr "$logs" : ".*$expect" >/dev/null; then | ||
return | ||
|
@@ -426,7 +451,7 @@ function wait_for_output { | |
exitcode=$output | ||
|
||
# One last chance: maybe the container exited just after logs cmd | ||
run_podman logs $cid | ||
run_podman 0+w logs $cid | ||
if expr "$logs" : ".*$expect" >/dev/null; then | ||
return | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is "e", that is, the warning is actually
level=error
. Should it be?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That LGTM. The man page states: "After exit of the container, remove the image unless another container is using it." It seems like a good idea to log when the image cannot be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full agreement on "there should be a warning". My question is, should it be
level=error
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for clarifying. I think a warning would be better than an error. It's perfectly fine behavior which does not classify as an error IMO.