catalyst-auto: add a time delay option
We usually run catalyst on systems via cronjob, and do so at weekly (or so) intervals. But if a failure hits a run, it will be a while before we know if changes fixed the situation. Instead, let's push the delay logic into the script itself so we can run this tool once a day. When it passes, it will take care of quitting early. When it fails, it will retry once a day until it passes.
This commit is contained in:
parent
880a1aa775
commit
f34a62d0ab
|
@ -25,6 +25,7 @@ verbose=0
|
||||||
keep_tmpdir=0
|
keep_tmpdir=0
|
||||||
testing=0
|
testing=0
|
||||||
preclean=0
|
preclean=0
|
||||||
|
lastrun=0
|
||||||
|
|
||||||
# Set pipefail so that run_cmd returns the right value in $?
|
# Set pipefail so that run_cmd returns the right value in $?
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
@ -46,6 +47,7 @@ Options:
|
||||||
-v|--verbose Send output of commands to console as well as log
|
-v|--verbose Send output of commands to console as well as log
|
||||||
-k|--keep-tmpdir Don't remove temp dir when build finishes
|
-k|--keep-tmpdir Don't remove temp dir when build finishes
|
||||||
-t|--test Stop after mangling specs and copying files
|
-t|--test Stop after mangling specs and copying files
|
||||||
|
--interval <days> Exit if last successful run was less than <days> ago
|
||||||
-h|--help Show this message and quit
|
-h|--help Show this message and quit
|
||||||
|
|
||||||
EOH
|
EOH
|
||||||
|
@ -124,6 +126,10 @@ do
|
||||||
-C|--preclean)
|
-C|--preclean)
|
||||||
preclean=1
|
preclean=1
|
||||||
;;
|
;;
|
||||||
|
--interval)
|
||||||
|
lastrun=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
usage "ERROR: You have specified an invalid option: ${a}"
|
usage "ERROR: You have specified an invalid option: ${a}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -151,6 +157,16 @@ fi
|
||||||
|
|
||||||
BUILD_SRCDIR_BASE=$(catalyst_var storedir)
|
BUILD_SRCDIR_BASE=$(catalyst_var storedir)
|
||||||
|
|
||||||
|
# See if we had a recent success.
|
||||||
|
if [[ ${lastrun} -ne 0 ]]; then
|
||||||
|
last_success_file="${BUILD_SRCDIR_BASE}/.last_success"
|
||||||
|
delay=$(( lastrun * 24 * 60 * 60 ))
|
||||||
|
last_success=$(head -1 "${last_success_file}" 2>/dev/null || echo 0)
|
||||||
|
if [[ $(date +%s) -lt $(( last_success + delay )) ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" catalyst-auto.XXXXXX)
|
TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" catalyst-auto.XXXXXX)
|
||||||
DATESTAMP=$(date +%Y%m%d)
|
DATESTAMP=$(date +%Y%m%d)
|
||||||
|
|
||||||
|
@ -298,6 +314,11 @@ if ! run_cmd "post_build" "${TMPDIR}/log/post_build.log"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${build_failure} = 0 ]; then
|
if [ ${build_failure} = 0 ]; then
|
||||||
|
if [[ ${lastrun} -ne 0 ]]; then
|
||||||
|
stamp=$(date)
|
||||||
|
(date -d"${stamp}" +%s; echo "${stamp}") >"${last_success_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
send_email "Catalyst build success" "Build process complete."
|
send_email "Catalyst build success" "Build process complete."
|
||||||
|
|
||||||
if [ "${keep_tmpdir}" = 0 ]; then
|
if [ "${keep_tmpdir}" = 0 ]; then
|
||||||
|
|
Loading…
Reference in a new issue