From 28e7b3467ba2a562099af4ea54dad34122188c6a Mon Sep 17 00:00:00 2001 From: David Esparza Date: Fri, 27 Oct 2023 15:40:55 -0600 Subject: [PATCH] metrics: improving stop and remove running containers This PR makes the change to using the SIGKILL signal instead of SIGTERM to force stop each kata component before start running any metric test. Fixes: #8336 Signed-off-by: David Esparza --- tests/common.bash | 3 ++- tests/metrics/lib/common.bash | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index 46dc9064a1..8497542ead 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -158,7 +158,7 @@ function clean_env_ctr() info "Wait until the containers gets removed" for task_id in "${running_tasks[@]}"; do - sudo timeout -s SIGKILL 30s ctr t kill -a -s SIGTERM ${task_id} >/dev/null 2>&1 || true + sudo timeout -s SIGKILL 30s ctr t kill -a -s SIGKILL ${task_id} >/dev/null 2>&1 || true sleep 0.5 done @@ -179,6 +179,7 @@ function clean_env_ctr() [ "$count_running" -eq 0 ] && break remaining_attempts=$((remaining_attempts-1)) + sleep 0.5 done count_tasks="$(sudo ctr t list -q | wc -l)" diff --git a/tests/metrics/lib/common.bash b/tests/metrics/lib/common.bash index 9fefd39a55..e7d253136d 100755 --- a/tests/metrics/lib/common.bash +++ b/tests/metrics/lib/common.bash @@ -176,13 +176,12 @@ function init_env() # restart docker only if it is not masked by systemd docker_masked="$(systemctl list-unit-files --state=masked | grep -c docker)" || true - if [ "${docker_masked}" -eq 0 ]; then - sudo systemctl restart docker - fi + [ "${docker_masked}" -eq 0 ] && sudo systemctl restart docker # This clean up is more aggressive, this is in order to # decrease the factors that could affect the metrics results. kill_processes_before_start + check_processes info "init environment complete" } @@ -201,9 +200,11 @@ function kill_processes_before_start() CTR_PROCS=$(sudo "${CTR_EXE}" t list -q) [[ -n "${CTR_PROCS}" ]] && clean_env_ctr - kill_kata_components && sleep 1 + restart_containerd_service + + # Remove all running containers + # and kills all the kata components kill_kata_components - check_processes } # Generate a random name - generally used when creating containers, but can