From c42a2f2eda5fd17fd3d6cdcfeb3f23abe6b9ff5d Mon Sep 17 00:00:00 2001 From: David Esparza Date: Tue, 24 Oct 2023 09:27:32 -0600 Subject: [PATCH] metrics: increase the number of attempts to stop kata This PR increases the number of attempts to stop kata components when it is required usually before starting a metrics test. Fixes: #8307 Signed-off-by: David Esparza --- tests/common.bash | 8 ++++++-- tests/metrics/lib/common.bash | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index a111445749..46dc9064a1 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -190,13 +190,17 @@ function clean_env_ctr() # Kills running shim and hypervisor components function kill_kata_components() { + local ATTEMPTS=2 local TIMEOUT="30s" local PID_NAMES=( "containerd-shim-kata-v2" "qemu-system-x86_64" "cloud-hypervisor" ) sudo systemctl stop containerd # iterate over the list of kata components and stop them - for PID_NAME in "${PID_NAMES[@]}"; do - [[ ! -z "$(pidof ${PID_NAME})" ]] && sudo killall "${PID_NAME}" > /dev/null 2>&1 || true + for (( i=1; i<=ATTEMPTS; i++ )); do + for PID_NAME in "${PID_NAMES[@]}"; do + [[ ! -z "$(pidof ${PID_NAME})" ]] && sudo killall "${PID_NAME}" >/dev/null 2>&1 || true + done + sleep 1 done sudo timeout -s SIGKILL "${TIMEOUT}" systemctl start containerd } diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index e42a596ac9..9fefd39a55 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -201,8 +201,8 @@ function kill_processes_before_start() CTR_PROCS=$(sudo "${CTR_EXE}" t list -q) [[ -n "${CTR_PROCS}" ]] && clean_env_ctr + kill_kata_components && sleep 1 kill_kata_components - check_processes }