diff options
author | Loys Ollivier <lollivier@baylibre.com> | 2017-12-27 11:49:58 +0100 |
---|---|---|
committer | Loys Ollivier <lollivier@baylibre.com> | 2017-12-27 13:41:21 +0100 |
commit | 1ae347940236ee33042cbc2dab3aa49565fbdcee (patch) | |
tree | 70c89cb72a372735a43e3bea893ef6b31595f575 /jjb | |
parent | 923c6db464b459bf14045370684d1a4f4f8a4633 (diff) |
jjb/common: lava-labs-prepare.sh
When device status was reserved, the script would exit and the job fail.
If device status is reserved poll the device status a limited amount of
time. If the status within the defined polling time changes continue
otherwise exit.
Polling as been set to 10 retries on the minute.
JIRA: SPEC-1210
Change-Id: I7ee950777f0881a4a588c9c0dc8db12a7f6dda4a
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
Diffstat (limited to 'jjb')
-rw-r--r-- | jjb/common/include-agl-lava-labs-prepare.sh | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh index 947e0862..8a40704a 100644 --- a/jjb/common/include-agl-lava-labs-prepare.sh +++ b/jjb/common/include-agl-lava-labs-prepare.sh @@ -84,14 +84,41 @@ for lab in "${!labs[@]}"; do device_status=${arr[2]} IFS=${OFS} - # device is only available if "idle" or "running" - device_available=0 - if [ x"$device_status" = x"idle" ]; then - device_available=1 - elif [ x"$device_status" = x"running" ]; then - device_available=1; + if [ x"$device_status" = x"reserved" ]; then + retries=10 + else + retries=1 fi + # If the device is reserved poll it's status every minutes. + # The max polling time is set to $retries * 60 seconds = 10 minutes. + for i in `seq 1 $retries` + do + # device is only available if "idle" or "running" + device_available=0 + if [ x"$device_status" = x"idle" ]; then + device_available=1 + break + elif [ x"$device_status" = x"running" ]; then + device_available=1; + break + fi + sleep 60s + # Find the LAVA Lab that has the device available to run the job + echo -n "Checking for $lava_device at $full_url... " + line=$(lava-tool devices-list $full_url | grep $lava_device) + line=$(echo "$line" | tr -d '[:space:]') + + if [ -z "$line" ]; then + echo "not found." + continue + fi + IFS='|' + arr=($line) + device_status=${arr[2]} + IFS=${OFS} + done + if [ $device_available = 0 ]; then echo " Not Available. Status: $device_status" continue |