performance-metrics: Kill stale processes on test timeout

When a test times out, the spawned thread containing the
cloud-hypervisor child process, iperf3/ethr sub processes,
and all associated resources (TAP devices, file descriptors,
hugepage reservations) is abandoned without cleanup. This
attaches a cleanup routine that kills cloud-hypervisor,
iperf3, and ethr processes on timeout, then waits
briefly for the kernel to reclaim their resources. This
prevents leaked processes from interfering with subsequent
tests.

Removes the existing TODO comment.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-03-11 20:45:31 +01:00
committed by Rob Bradford
parent 5b55286099
commit 57e64a0848

View File

@@ -1214,7 +1214,6 @@ fn run_test_with_timeout(
let _ = sender.send(output);
});
// Todo: Need to cleanup/kill all hanging child processes
let test_timeout = test.calc_timeout(&test_iterations, &test_timeout);
receiver
.recv_timeout(Duration::from_secs(test_timeout))
@@ -1223,10 +1222,18 @@ fn run_test_with_timeout(
"[Error] Test '{}' time-out after {} seconds",
test.name, test_timeout
);
cleanup_stale_processes();
Error::TestTimeout
})?
}
fn cleanup_stale_processes() {
for proc in &["cloud-hypervisor", "iperf3", "ethr"] {
let _ = Command::new("pkill").args(["-9", "-f", proc]).status();
}
thread::sleep(Duration::from_secs(2));
}
fn date() -> String {
let output = test_infra::exec_host_command_output("date");
String::from_utf8_lossy(&output.stdout).trim().to_string()