Merge "Fix Shipyard wait to catch errors that occur in steps"
This commit is contained in:
commit
1a445f3c0b
|
@ -93,24 +93,36 @@ shipyard_action_wait() {
|
||||||
log "Shipyard action ${action} did not complete in ${timeout} seconds."
|
log "Shipyard action ${action} did not complete in ${timeout} seconds."
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
RESULT=$(shipyard_cmd --output-format=raw describe "${ACTION_ID}")
|
|
||||||
ACTION_STATUS=$(echo "${RESULT}" | jq -r '.action_lifecycle')
|
|
||||||
ACTION_RESULT=$(echo "${RESULT}" | jq -r '.dag_status')
|
|
||||||
|
|
||||||
if [[ "${ACTION_STATUS}" == "Complete" ]]
|
ACTION_STATUS=$(shipyard_cmd describe "${ACTION_ID}" | grep -i "Lifecycle" | \
|
||||||
then
|
awk '{print $2}')
|
||||||
if [[ "${ACTION_RESULT}" == "success" ]]
|
|
||||||
then
|
ACTION_STEPS=$(shipyard_cmd describe "${ACTION_ID}" | grep -i "step/" | \
|
||||||
log "Shipyard action ${action} success!"
|
awk '{print $3}')
|
||||||
return 0
|
|
||||||
else
|
# Verify lifecycle status
|
||||||
log "Shipyard action ${action} completed with result ${ACTION_RESULT}"
|
if [ "${ACTION_STATUS}" == "Failed" ]; then
|
||||||
echo "${RESULT}" | jq >> "${LOG_FILE}"
|
echo -e "\n${ACTION_ID} FAILED\n"
|
||||||
return 1
|
shipyard_cmd describe "${ACTION_ID}"
|
||||||
fi
|
exit 1
|
||||||
else
|
|
||||||
sleep "${poll_time}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${ACTION_STATUS}" == "Complete" ]; then
|
||||||
|
# Verify status of each action step
|
||||||
|
for step in ${ACTION_STEPS}; do
|
||||||
|
if [ "${step}" == "failed" ]; then
|
||||||
|
echo -e "\n${ACTION_ID} FAILED\n"
|
||||||
|
shipyard_cmd describe "${ACTION_ID}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e "\n${ACTION_ID} completed SUCCESSFULLY\n"
|
||||||
|
shipyard_cmd describe "${ACTION_ID}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep "${poll_time}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue