jjb/common: Fix race condition when using grep and tr 87/12587/3
authorLoys Ollivier <lollivier@baylibre.com>
Thu, 14 Dec 2017 10:31:20 +0000 (11:31 +0100)
committerLoys Ollivier <lollivier@baylibre.com>
Fri, 15 Dec 2017 10:08:52 +0000 (11:08 +0100)
when using grep + tr to find board availability, status, a race
condition happens sometimes. When it happens the job is stuck and
timeout fails.

Fix it by calling sequentially grep then tr and not piping.

Change-Id: Ib1322e280900b62abdd827992b42183024cd094c
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
jjb/common/include-agl-lava-jobs-submit.sh
jjb/common/include-agl-lava-labs-prepare.sh

index 217e8da..3703ce5 100644 (file)
@@ -31,7 +31,8 @@ job_id=$(grep "submitted as job:" $JOB_STATUS | sed 's/.*\/\([0-9]*$\)/\1/')
 lava-tool job-details $full_url $job_id | tee $JOB_STATUS
 
 IFS=':'
-line=$(grep "^status:" $JOB_STATUS | tr -d '[:space:]')
+line=$(grep "^status:" $JOB_STATUS)
+line=$(echo "$line" | tr -d '[:space:]')
 arr=($line)
 status=${arr[1]}
 IFS=${OFS}
index 0b54f9f..f02a2b3 100644 (file)
@@ -68,7 +68,9 @@ for lab in "${!labs[@]}"; do
 
     # 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 | tr -d '[:space:]')
+    line=$(lava-tool devices-list $full_url | grep $lava_device)
+    line=$(echo "$line" | tr -d '[:space:]')
+
     if [ -z "$line" ]; then
         echo "not found."
         continue