Skip to content

Commit 4b1b1e0

Browse files
committed
Tests that containers can be deleted when the runc creation process is killed by SIGKILL
Signed-off-by: HirazawaUi <[email protected]>
1 parent 29dcef9 commit 4b1b1e0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/integration/delete.bats

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,43 @@ EOF
276276
# Expect "no such unit" exit code.
277277
run -4 systemctl status $user "$SD_UNIT_NAME"
278278
}
279+
280+
@test "runc delete after create process killed" {
281+
# This test verifies that a container can be properly deleted
282+
# even if the runc create process was killed with SIGKILL
283+
284+
requires root cgroups_v1
285+
set_cgroups_path
286+
287+
# Add many device rules to further slow down cgroup creation
288+
update_config '.linux.resources.devices = []'
289+
for i in {1..300}; do
290+
update_config '.linux.resources.devices += [{"allow": true, "access": "rwm", "type": "c", "major": '"$i"', "minor": 0}]'
291+
done
292+
293+
# Start runc create and kill it after 5ms with SIGKILL
294+
timeout --signal=SIGKILL --kill-after=0 0.05s "$RUNC" --debug ${RUNC_USE_SYSTEMD+--systemd-cgroup} --root "$ROOT/state" create --console-socket "$CONSOLE_SOCKET" test_create_killed || true
295+
296+
# Wait briefly to ensure background processes complete
297+
sleep 1
298+
299+
# Check container state - should be in stopped or paused state after SIGKILL
300+
runc state test_create_killed
301+
[ "$status" -eq 0 ]
302+
[[ "$output" == *"stopped"* || "$output" == *"paused"* ]]
303+
304+
runc delete --force test_create_killed
305+
[ "$status" -eq 0 ]
306+
307+
# Verify container no longer exists in the list
308+
runc list
309+
[[ "$output" != *"test_create_killed"* ]]
310+
311+
# Check for any leftover runc init processes
312+
remaining_inits=$(pgrep -f "runc.*init.*test_create_killed" || true)
313+
[ -z "$remaining_inits" ] || fail "leftover runc init processes: $remaining_inits"
314+
315+
# Check for leftover cgroups using standard pattern
316+
output=$(find /sys/fs/cgroup -path "$REL_CGROUPS_PATH" 2>/dev/null || true)
317+
[ -z "$output" ] || fail "leftover cgroups found: $output"
318+
}

0 commit comments

Comments
 (0)