mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-09 03:48:05 +00:00
Merge pull request #7530 from dborquez/fix_check_running_processes
metrics: stop kata components before start a metric test.
This commit is contained in:
commit
7d1c48c881
@ -186,31 +186,20 @@ function clean_env_ctr()
|
|||||||
if (( count_tasks > 0 )); then
|
if (( count_tasks > 0 )); then
|
||||||
die "Can't remove running containers."
|
die "Can't remove running containers."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kill_kata_components
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Kills running shim and hypervisor components
|
# Kills running shim and hypervisor components
|
||||||
|
# by using the kata-component file name.
|
||||||
function kill_kata_components() {
|
function kill_kata_components() {
|
||||||
local kata_bin_dir="/opt/kata/bin"
|
local PID_NAMES=( "containerd-shim-kata-v2" "qemu-system-x86_64" "cloud-hypervisor" )
|
||||||
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)"
|
|
||||||
|
|
||||||
[ ${pid_shim_count} -gt "0" ] && sudo kill -SIGKILL "$(pgrep -f ${shim_path})" > /dev/null 2>&1
|
sudo systemctl stop containerd
|
||||||
|
# Get the filenames of the kata components
|
||||||
if [ "${KATA_HYPERVISOR}" = 'clh' ]; then
|
# and kill the correspondingt processes
|
||||||
hypervisor_path="${kata_bin_dir}/cloud-hypervisor"
|
for PID_NAME in ${PID_NAMES} ; do
|
||||||
elif [ "${KATA_HYPERVISOR}" != 'qemu' ]; then
|
sudo killall ${PID_NAME} > /dev/null 2>&1 || true
|
||||||
echo "Failed to stop the hypervisor: '${KATA_HYPERVISOR}' as it is not recognized"
|
done
|
||||||
return
|
sudo systemctl start containerd
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restarts a systemd service while ensuring the start-limit-burst is set to 0.
|
# 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)
|
CTR_PROCS=$(sudo "${CTR_EXE}" t list -q)
|
||||||
[[ -n "${CTR_PROCS}" ]] && clean_env_ctr
|
[[ -n "${CTR_PROCS}" ]] && clean_env_ctr
|
||||||
|
|
||||||
|
kill_kata_components
|
||||||
|
|
||||||
check_processes
|
check_processes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ run_workload() {
|
|||||||
# number of decimal digits after the decimal points
|
# number of decimal digits after the decimal points
|
||||||
# for 'bc' performing math in kernel period estimation
|
# for 'bc' performing math in kernel period estimation
|
||||||
L_CALC_SCALE=13
|
L_CALC_SCALE=13
|
||||||
|
local CONTAINER_NAME="kata_launch_times_$(( $RANDOM % 1000 + 1))"
|
||||||
start_time=$($DATECMD)
|
start_time=$($DATECMD)
|
||||||
|
|
||||||
# Check entropy level of the host
|
# Check entropy level of the host
|
||||||
@ -103,8 +104,7 @@ run_workload() {
|
|||||||
|
|
||||||
# Run the image and command and capture the results into an array...
|
# Run the image and command and capture the results into an array...
|
||||||
declare workload_result
|
declare workload_result
|
||||||
readarray -n 0 workload_result < <(sudo -E "${CTR_EXE}" run --rm --runtime=${CTR_RUNTIME} ${IMAGE} test bash -c "$DATECMD $DMESGCMD")
|
readarray -n 0 workload_result < <(sudo -E "${CTR_EXE}" run --rm --runtime ${CTR_RUNTIME} ${IMAGE} ${CONTAINER_NAME} bash -c "$DATECMD $DMESGCMD")
|
||||||
|
|
||||||
end_time=$($DATECMD)
|
end_time=$($DATECMD)
|
||||||
|
|
||||||
# Delay this calculation until after we have run - do not want
|
# Delay this calculation until after we have run - do not want
|
||||||
|
Loading…
Reference in New Issue
Block a user