aboutsummaryrefslogtreecommitdiffstats
path: root/jjb/common/include-agl-lava-jobs-submit.sh
diff options
context:
space:
mode:
authorKhouloud Touil <ktouil@baylibre.com>2019-07-12 14:45:37 +0200
committerKhouloud Touil <ktouil@baylibre.com>2019-07-26 17:11:06 +0200
commit7a4248260d211abf66cf8d9c5dbd30c91e063c67 (patch)
tree2b8b3d330be17a7662a9750618df2df8d5abd737 /jjb/common/include-agl-lava-jobs-submit.sh
parente4a5da8ff2d49d9a85d9cc0db20a995d557fec68 (diff)
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 <ktouil@baylibre.com> Change-Id: Ic81a635b0cc2dc5dda3028aefb78f88be0d79a31
Diffstat (limited to 'jjb/common/include-agl-lava-jobs-submit.sh')
-rw-r--r--jjb/common/include-agl-lava-jobs-submit.sh46
1 files changed, 7 insertions, 39 deletions
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 "####"