mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 00:37:24 +00:00
metrics: skips docker restart when it is not installed or is masked.
To avoid errors when initializing the test environment, the kill_processes_before_start() helper function needs to verify that docker is installed before attempting to stop it. Fixes: #8218 Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
This commit is contained in:
parent
c2763120aa
commit
908519db9d
@ -168,15 +168,18 @@ function init_env()
|
|||||||
|
|
||||||
cmd=("docker" "ctr")
|
cmd=("docker" "ctr")
|
||||||
|
|
||||||
sudo systemctl restart docker
|
|
||||||
|
|
||||||
# check dependencies
|
# check dependencies
|
||||||
check_cmds "${cmd[@]}"
|
check_cmds "${cmd[@]}"
|
||||||
|
|
||||||
# Remove all stopped containers
|
# Remove all stopped containers
|
||||||
clean_env
|
|
||||||
clean_env_ctr
|
clean_env_ctr
|
||||||
|
|
||||||
|
# restart docker only if it is not masked by systemd
|
||||||
|
docker_masked="$(systemctl list-unit-files --state=masked | grep -c docker)"
|
||||||
|
if [ "${docker_masked}" -eq 0 ]; then
|
||||||
|
sudo systemctl restart docker
|
||||||
|
fi
|
||||||
|
|
||||||
# This clean up is more aggressive, this is in order to
|
# This clean up is more aggressive, this is in order to
|
||||||
# decrease the factors that could affect the metrics results.
|
# decrease the factors that could affect the metrics results.
|
||||||
kill_processes_before_start
|
kill_processes_before_start
|
||||||
@ -188,8 +191,12 @@ function init_env()
|
|||||||
# killed to start test with clean environment.
|
# killed to start test with clean environment.
|
||||||
function kill_processes_before_start()
|
function kill_processes_before_start()
|
||||||
{
|
{
|
||||||
DOCKER_PROCS=$(sudo "${DOCKER_EXE}" ps -q)
|
docker_masked="$(systemctl list-unit-files --state=masked | grep -c "${DOCKER_EXE}")"
|
||||||
[[ -n "${DOCKER_PROCS}" ]] && clean_env
|
|
||||||
|
if [ "${docker_masked}" -eq 0 ]; then
|
||||||
|
DOCKER_PROCS=$(sudo "${DOCKER_EXE}" ps -q)
|
||||||
|
[[ -n "${DOCKER_PROCS}" ]] && clean_env
|
||||||
|
fi
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user