mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
5b55286099
commit
57e64a0848
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user