Skip to content

Commit 9fada28

Browse files
committed
Add bats test for zombie conmon cleanup
In cri-o#5500, defensive code was added to ensure all child processes are cleaned up when conmon early initialization fails. This bats test forces one of the error scenarios (by adding an unparseable workload annotation to a container) and then ensures no zombies leak in this failure scenario. Verified by temporarily reverting cri-o#5500 (test fails with 10 zombies created), then bringing back cri-o#5500 (test passes) Signed-off-by: Jim Ramsay <[email protected]>
1 parent 3be57f5 commit 9fada28

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/pod.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bats
2+
# vim:set ft=bash :
23

34
load helpers
45

test/workloads.bats

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bats
2+
# vim:set ft=bash :
23

34
load helpers
45

@@ -327,3 +328,35 @@ function check_conmon_fields() {
327328
df=$(crictl exec --sync "$ctr_id" df | grep /dev/shm)
328329
[[ "$df" == *'16384'* ]]
329330
}
331+
332+
@test "test resource cleanup on bad annotation contents" {
333+
shares="200"
334+
set="0-2"
335+
name=helloctr
336+
create_workload "$shares" "0"
337+
338+
start_crio
339+
340+
jq --arg act "$activation" --arg set "{\"cpuset\": \"$set\"}" --arg setkey "$prefix/$name" \
341+
' .annotations[$act] = "true"
342+
| .annotations[$setkey] = $set' \
343+
"$TESTDATA"/sandbox_config.json > "$sboxconfig"
344+
pod_id=$(crictl runp "$sboxconfig")
345+
346+
# Forceibly fail 10 container creations via bad workload annotation:
347+
for id in {1..10}; do
348+
ctrconfig="$TESTDIR/ctr-$id.json"
349+
jq --arg act "$activation" --arg name "$name-$id" --arg set "invalid & unparsable {\"cpuset\": \"$set\"}" --arg setkey "$prefix/POD" \
350+
' .annotations[$act] = "true"
351+
| .annotations[$setkey] = $set
352+
| .metadata.name = $name' \
353+
"$TESTDATA"/container_sleep.json > "$ctrconfig"
354+
ctr_id=$(crictl create "$pod_id" "$ctrconfig" "$sboxconfig" || true)
355+
[[ $ctr_id == "" ]]
356+
done
357+
# Ensure there are no conmon zombies leftover
358+
children=$(ps --ppid "$CRIO_PID" -o state= -o pid= -o cmd= || true)
359+
zombies=$(grep -c '^Z ' <<< "$children" || true)
360+
echo "Zombies: $zombies"
361+
[[ $zombies == 0 ]]
362+
}

0 commit comments

Comments
 (0)