Fix bug that start_job script exit unexpectedly 61/40561/2
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Tue, 29 Aug 2017 07:11:44 +0000 (15:11 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Tue, 29 Aug 2017 07:25:56 +0000 (15:25 +0800)
When `set -o errexit` is enabled in script, the non-zero return value
from `diff` is considered as an error. But actually diff returns 1 when
difference is found. The error exit option should be disabled when dealing
`diff`.

Change-Id: I6270ec8f7036b3d752736a80474468e26a613585
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
resources/ansible_roles/storperf/files/start_job.sh

index 19ddbd2..7905729 100755 (executable)
@@ -99,11 +99,15 @@ else
         curl -s -X GET "${storperf_api}/jobs?id=$JOB&type=status" \
             -o $WORKSPACE/status.json
         JOB_STATUS=`cat $WORKSPACE/status.json | awk '/Status/ {print $2}' | cut -d\" -f2`
+
+        set +o errexit # disable error exit checking for diff
         diff $WORKSPACE/status.json $WORKSPACE/old-status.json >/dev/null
         if [ $? -eq 1 ]
         then
             cat $WORKSPACE/status.json
         fi
+        set -o errexit
+
     done
 
     echo