From 7a4248260d211abf66cf8d9c5dbd30c91e063c67 Mon Sep 17 00:00:00 2001 From: Khouloud Touil Date: Fri, 12 Jul 2019 14:45:37 +0200 Subject: Manage the polling with lavacli Instead of using a timeout to manage the polling part, this patch replace it with a lavacli command which is 'lavacli jobs wait'that will wait for the job to finish, but after 2 hours the 'job wait' will be stopped even the job if not finished, we are estimating after a 2 hours of waiting, a problem is occurring in the job. Signed-off-by: Khouloud Touil Change-Id: Ic81a635b0cc2dc5dda3028aefb78f88be0d79a31 --- jjb/common/include-agl-lava-jobs-submit.sh | 46 +++++------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'jjb') diff --git a/jjb/common/include-agl-lava-jobs-submit.sh b/jjb/common/include-agl-lava-jobs-submit.sh index 46172751..0f7844f3 100644 --- a/jjb/common/include-agl-lava-jobs-submit.sh +++ b/jjb/common/include-agl-lava-jobs-submit.sh @@ -41,46 +41,14 @@ echo "Submitted as job: $JOB_URL" echo "" echo "####################################################" echo "" -# -# LAVA job details, get job status from lavacli output -# -# There is no version of blocking call (--block) for lavacli -# If the job didn't finish after JOB_TIMEOUT, will exit and display -# an error message -# example: lava-slave crash -if [ -z $JOB_TIMEOUT ]; then - # if the JOB_TIMEOUT is not set, it's 1 hour by default - JOB_TIMEOUT=360 -fi -# FIXME: this section needs to run under set +e -set +e -for i in $(seq 1 $JOB_TIMEOUT); do - lavacli -i $lab jobs show $job_id --yaml > $JOB_STATUS - if [ $? -ne 0 ];then - # be patient in case of a temporary error - sleep 10 - continue - fi - state=$(grep ^state: $JOB_STATUS| cut -d' ' -f2) - if [ $state == "Canceled" ]; then - status=$(grep ^health: $JOB_STATUS| cut -d' ' -f2) - echo "LAVA job $job_id completed with status: $status" - break - fi - if [ $state == "Finished" ]; then - status=$(grep ^health: $JOB_STATUS| cut -d' ' -f2) - echo "LAVA job $job_id completed with status: $status" - break - fi - sleep 10 -done -set -e -# enable set -e again - -if [ $i -ge $JOB_TIMEOUT ];then - echo "ERROR: job did not finished before 1 hour" - exit 1 +# use lavacli wait job instead of the polling. +lavacli -i agl jobs wait $job_id --timeout 7200 +lavacli -i agl jobs show $job_id --yaml > $JOB_STATUS +state=$(grep ^state: $JOB_STATUS| cut -d' ' -f2) +if [ "$state" == "Finished" ]; then + status=$(grep ^health: $JOB_STATUS| cut -d' ' -f2) + echo "LAVA job $job_id completed with status: $status" fi echo "####" -- cgit 1.2.3-korg