mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
metrics: Add check containers are up in tensorflow mobilenet script
This PR adds the check containers are up in the common script in the tensorflow mobilenet script. Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
parent
9d57a1fab4
commit
918c783084
@ -363,18 +363,18 @@ function wait_ksm_settle()
|
||||
}
|
||||
|
||||
function collect_results() {
|
||||
WORKLOAD=${1}
|
||||
[[ -z ${WORKLOAD} ]] && die "Container workload is missing"
|
||||
local WORKLOAD="$1"
|
||||
[[ -z "${WORKLOAD}" ]] && die "Container workload is missing"
|
||||
|
||||
local tasks_running=("${containers[@]}")
|
||||
local retries=100
|
||||
|
||||
while [ "${#tasks_running[@]}" -gt 0 ] && [ "${retries}" -gt 0 ]; do
|
||||
for i in "${!tasks_running[@]}"; do
|
||||
check_file=$(sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${tasks_running[i]}" sh >
|
||||
check_file=$(sudo -E "${CTR_EXE}" t exec --exec-id "$(random_name)" "${tasks_running[i]}" sh -c "${WORKLOAD}")
|
||||
|
||||
# if the current task is done, remove the corresponding container from the active list
|
||||
[ "${check_file}" -eq "1" ] && unset 'tasks_running[i]'
|
||||
[ "${check_file}" = 1 ] && unset 'tasks_running[i]'
|
||||
done
|
||||
((retries--))
|
||||
sleep 3
|
||||
@ -385,7 +385,7 @@ function collect_results() {
|
||||
|
||||
function check_containers_are_up() {
|
||||
local NUM_CONTAINERS="$1"
|
||||
[[ -z ${NUM_CONTAINERS} ]] && die "Number of containers is missing"
|
||||
[[ -z "${NUM_CONTAINERS}" ]] && die "Number of containers is missing"
|
||||
|
||||
local TIMEOUT=60
|
||||
local containers_launched=0
|
||||
|
@ -109,17 +109,6 @@ EOF
|
||||
metrics_json_end_array "Results"
|
||||
}
|
||||
|
||||
function check_containers_are_up() {
|
||||
local containers_launched=0
|
||||
for i in $(seq "${TIMEOUT}") ; do
|
||||
info "Verify that the containers are running"
|
||||
containers_launched="$(sudo ${CTR_EXE} t list | grep -c "RUNNING")"
|
||||
[ "${containers_launched}" -eq "${NUM_CONTAINERS}" ] && break
|
||||
sleep 1
|
||||
[ "${i}" == "${TIMEOUT}" ] && return 1
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
# Verify enough arguments
|
||||
if [ $# != 2 ]; then
|
||||
@ -153,11 +142,11 @@ function main() {
|
||||
metrics_json_start_array
|
||||
|
||||
# Check that the requested number of containers are running
|
||||
check_containers_are_up
|
||||
check_containers_are_up "${NUM_CONTAINERS}"
|
||||
|
||||
# Check that the requested number of containers are running
|
||||
local timeout_launch="10"
|
||||
check_containers_are_up & pid=$!
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user