From 00a7f42b60833d481f6476fee453c1192a395a0b Mon Sep 17 00:00:00 2001 From: Khouloud Touil Date: Tue, 2 Apr 2019 10:49:17 +0200 Subject: Replace lava-tool with lavacli In order to move totally to lavacli, this patch: - Apply changes to submit jobs using lavacli. As the blocking call (--block) no longer exists with lavacli, so had to replace that with a polling loop. - Replace lava-tool with lavacli in the polling part in the labs-prepare file, which checks the device status and availability. Different changes tested at Baylibre. Change-Id: I25b1ad4b47ae09a158e1e1cf42e30da5e6aa8b57 Signed-off-by: Khouloud Touil --- jjb/common/include-agl-lava-jobs-submit-only.sh | 10 +++-- jjb/common/include-agl-lava-jobs-submit.sh | 50 ++++++++++++++++++------- jjb/common/include-agl-lava-labs-prepare.sh | 26 ++++++------- 3 files changed, 55 insertions(+), 31 deletions(-) (limited to 'jjb/common') diff --git a/jjb/common/include-agl-lava-jobs-submit-only.sh b/jjb/common/include-agl-lava-jobs-submit-only.sh index a8354390..f2a20fe0 100644 --- a/jjb/common/include-agl-lava-jobs-submit-only.sh +++ b/jjb/common/include-agl-lava-jobs-submit-only.sh @@ -19,8 +19,12 @@ cat $JOB_FILE | sed "s/device_type: $releng_device$/device_type: $lava_device/" # # LAVA job submit, get job ID from lava-tool output # -JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status" -lava-tool submit-job --block $full_url $JOB_FILE_NEW |tee $JOB_STATUS +job_id=$(lavacli -i $lab jobs submit $JOB_FILE_NEW) +if [ $? -ne 0 ]; then + echo "ERROR: job submission error" + exit 1 +fi # Printing the job URL in the log -grep "submitted as job:" $JOB_STATUS +JOB_URL="${url}scheduler/job/${job_id}" +echo "Submitted as job: $JOB_URL" diff --git a/jjb/common/include-agl-lava-jobs-submit.sh b/jjb/common/include-agl-lava-jobs-submit.sh index 22dc0c3b..30f11ee3 100644 --- a/jjb/common/include-agl-lava-jobs-submit.sh +++ b/jjb/common/include-agl-lava-jobs-submit.sh @@ -20,24 +20,48 @@ cat $JOB_FILE | sed "s/device_type: $releng_device$/device_type: $lava_device/" # LAVA job submit, get job ID from lava-tool output # JOB_STATUS="${JOB_BASE}_${LAVA_LAB}.status" -lava-tool submit-job --block $full_url $JOB_FILE_NEW |tee $JOB_STATUS + +job_id=$(lavacli -i $lab jobs submit $JOB_FILE_NEW) +if [ $? -ne 0 ]; then + echo "ERROR: job submission error" + exit 1 +fi # Printing the job URL in the log -grep "submitted as job:" $JOB_STATUS -job_id=$(grep "submitted as job:" $JOB_STATUS | sed 's/.*\/\([0-9]*$\)/\1/') +echo "THe job id is: ${job_id}" +JOB_URL="${url}scheduler/job/${job_id}" +echo "Submitted as job: $JOB_URL" # -# LAVA job details, get job status from lava-tool output +# LAVA job details, get job status from lavacli output # -lava-tool job-details $full_url $job_id | tee $JOB_STATUS - -IFS=':' -line=$(grep "^status:" $JOB_STATUS) -line=$(echo "$line" | tr -d '[:space:]') -arr=($line) -status=${arr[1]} -IFS=${OFS} +# 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 ] + # if the JOB_TIMEOUT is not set, it's 1 hour by default + JOB_TIMEOUT=360 +fi -echo "LAVA job $job_id completed with status: $status" +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 == "Finished" ]; then + status=$(grep ^Health: $JOB_STATUS| cut -d' ' -f2) + echo "LAVA job $job_id completed with status: $status" + break + fi + sleep 10 +done +if [ $i -ge $JOB_TIMEOUT ];then + echo "ERROR: job did not finished before 1 hour" + exit 1 +fi echo "####" echo "#### Start: Output from LAVA job $job_id ####" diff --git a/jjb/common/include-agl-lava-labs-prepare.sh b/jjb/common/include-agl-lava-labs-prepare.sh index f32e16f9..19801e13 100644 --- a/jjb/common/include-agl-lava-labs-prepare.sh +++ b/jjb/common/include-agl-lava-labs-prepare.sh @@ -75,7 +75,7 @@ for lab in "${!labs[@]}"; do # lavacli: Find the LAVA lab that has the device available to run the job echo -n "lavacli: Checking for $lava_device at $full_url... " - lavacli_line=$(lavacli -i $lab devices list | grep $lava_device | grep Idle,Good | head -1) + lavacli_line=$(lavacli -i $lab devices list | grep $lava_device | grep Good | head -1) lavacli_line=$(echo "$lavacli_line" | tr -d '[:space:]') if [ -z "$lavacli_line" ]; then @@ -105,12 +105,8 @@ for lab in "${!labs[@]}"; do echo "not found." continue fi - IFS='|' - arr=($line) - device_status=${arr[2]} - IFS=${OFS} - if [ x"$device_status" = x"reserved" ]; then + if [ x"$device_status" = x"Reserved,Good" ]; then retries=10 else retries=1 @@ -122,26 +118,26 @@ for lab in "${!labs[@]}"; do do # device is only available if "idle" or "running" device_available=0 - if [ x"$device_status" = x"reserved" ]; then + if [ x"$device_status" = x"Reserved,Good" ]; 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:]') + lavacli_line=$(lavacli -i $lab devices list | grep $lava_device | grep Good | head -1) + lavacli_line=$(echo "$lavacli_line" | tr -d '[:space:]') - if [ -z "$line" ]; then + if [ -z "$lavacli_line" ]; then echo "not found." continue fi - IFS='|' - arr=($line) - device_status=${arr[2]} + IFS=':' + arr=($lavacli_line) + device_status=${arr[1]} IFS=${OFS} fi - if [ x"$device_status" = x"idle" ]; then + if [ x"$device_status" = x"Idle,Good" ]; then device_available=1 break - elif [ x"$device_status" = x"running" ]; then + elif [ x"$device_status" = x"Running,Good" ]; then device_available=1; break fi -- cgit 1.2.3-korg