Merge pull request #8338 from dborquez/improve_metrics_init_environment

metrics: Fix function that completely stops kata containers before running a test
This commit is contained in:
David Esparza
2023-11-13 09:35:27 -06:00
committed by GitHub
2 changed files with 8 additions and 6 deletions

View File

@@ -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)"

View File

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