mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
metrics: Clean kata components before start a metric test.
This PR kills all kata components before start a new metric test. Fixes: #7528 Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
This commit is contained in:
parent
d424f3c595
commit
5dbe88330f
@ -186,31 +186,20 @@ function clean_env_ctr()
|
||||
if (( count_tasks > 0 )); then
|
||||
die "Can't remove running containers."
|
||||
fi
|
||||
|
||||
kill_kata_components
|
||||
}
|
||||
|
||||
# Kills running shim and hypervisor components
|
||||
# by using the kata-component file name.
|
||||
function kill_kata_components() {
|
||||
local kata_bin_dir="/opt/kata/bin"
|
||||
local shim_path="${kata_bin_dir}/containerd-shim-kata-v2"
|
||||
local hypervisor_path="${kata_bin_dir}/qemu-system-x86_64"
|
||||
local pid_shim_count="$(pgrep -fc ${shim_path} || exit 0)"
|
||||
local PID_NAMES=( "containerd-shim-kata-v2" "qemu-system-x86_64" "cloud-hypervisor" )
|
||||
|
||||
[ ${pid_shim_count} -gt "0" ] && sudo kill -SIGKILL "$(pgrep -f ${shim_path})" > /dev/null 2>&1
|
||||
|
||||
if [ "${KATA_HYPERVISOR}" = 'clh' ]; then
|
||||
hypervisor_path="${kata_bin_dir}/cloud-hypervisor"
|
||||
elif [ "${KATA_HYPERVISOR}" != 'qemu' ]; then
|
||||
echo "Failed to stop the hypervisor: '${KATA_HYPERVISOR}' as it is not recognized"
|
||||
return
|
||||
fi
|
||||
|
||||
local pid_hypervisor_count="$(pgrep -fc ${hypervisor_path} || exit 0)"
|
||||
|
||||
if [ ${pid_hypervisor_count} -gt "0" ]; then
|
||||
sudo kill -SIGKILL "$(pgrep -f ${hypervisor_path})" > /dev/null 2>&1
|
||||
fi
|
||||
sudo systemctl stop containerd
|
||||
# Get the filenames of the kata components
|
||||
# and kill the correspondingt processes
|
||||
for PID_NAME in ${PID_NAMES} ; do
|
||||
sudo killall ${PID_NAME} > /dev/null 2>&1 || true
|
||||
done
|
||||
sudo systemctl start containerd
|
||||
}
|
||||
|
||||
# Restarts a systemd service while ensuring the start-limit-burst is set to 0.
|
||||
|
@ -192,6 +192,8 @@ function kill_processes_before_start()
|
||||
CTR_PROCS=$(sudo "${CTR_EXE}" t list -q)
|
||||
[[ -n "${CTR_PROCS}" ]] && clean_env_ctr
|
||||
|
||||
kill_kata_components
|
||||
|
||||
check_processes
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user