jjb/common: lava-labs-prepare.sh fix polling on reserved boards 13/13113/1
authorLoys Ollivier <lollivier@baylibre.com>
Wed, 3 Jan 2018 17:04:59 +0000 (18:04 +0100)
committerLoys Ollivier <lollivier@baylibre.com>
Wed, 3 Jan 2018 17:04:59 +0000 (18:04 +0100)
The script would still wait for 60 seconds and retry on boards that are
not in the reserved state.

Fix this and poll for a change of status only if the board is reserved.

Fixes: 1ae347940236 ("jjb/common: lava-labs-prepare.sh")
Change-Id: I4ce71979f7cb2856768de748c1afb6a1cfb47ca2
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
jjb/common/include-agl-lava-labs-prepare.sh

index 8a40704..35d3541 100644 (file)
@@ -96,6 +96,22 @@ for lab in "${!labs[@]}"; do
     do
         # device is only available if "idle" or "running"
         device_available=0
+        if [ x"$device_status" = x"reserved" ]; then
+            sleep 60s
+            # Look if the status of the board has changed from reserved in the lab
+            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}
+        fi
         if [ x"$device_status" = x"idle" ]; then
             device_available=1
             break
@@ -103,20 +119,6 @@ for lab in "${!labs[@]}"; do
             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