mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 03:42:09 +00:00
metrics: Add check containers are running function
This PR adds the check containers are running function the common metrics script. Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
parent
918c783084
commit
833cf7a684
@ -397,3 +397,21 @@ function check_containers_are_up() {
|
||||
[ "${i}" == "${TIMEOUT}" ] && return 1
|
||||
done
|
||||
}
|
||||
|
||||
function check_containers_are_running() {
|
||||
local NUM_CONTAINERS="$1"
|
||||
[[ -z "${NUM_CONTAINERS}" ]] && die "Number of containers is missing"
|
||||
|
||||
# Check that the requested number of containers are running
|
||||
local timeout_launch="10"
|
||||
check_containers_are_up "${NUM_CONTAINERS}" & pid=$!
|
||||
(sleep "${timeout_launch}" && kill -HUP "${pid}") 2>/dev/null & pid_tout=$!
|
||||
|
||||
if wait "${pid}" 2>/dev/null; then
|
||||
pkill -HUP -P "${pid_tout}"
|
||||
wait "${pid_tout}"
|
||||
else
|
||||
warn "Time out exceeded"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user