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 <david.esparza.borquez@intel.com>
(cherry picked from commit c42a2f2eda)
This commit is contained in:
David Esparza 2023-10-24 09:27:32 -06:00 committed by Fabiano Fidêncio
parent aa8a96fe51
commit 885fcc9aaa
2 changed files with 7 additions and 3 deletions

View File

@ -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 (( 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
[[ ! -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
}

View File

@ -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
}