From 0c57f232cee070f0e2e95e4ac55084bb330380f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=BCtt?= Date: Tue, 19 Mar 2019 11:44:25 +0100 Subject: [PATCH] Docker: Handle preemption gracefully --- tools/docker/scripts/ci_entrypoint.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/docker/scripts/ci_entrypoint.sh b/tools/docker/scripts/ci_entrypoint.sh index d4a6d528f4..efee7c923f 100755 --- a/tools/docker/scripts/ci_entrypoint.sh +++ b/tools/docker/scripts/ci_entrypoint.sh @@ -29,6 +29,16 @@ function upload_file { wget --quiet --output-document=- --method=PUT --header="content-type: ${CONTENT_TYPE}" --header="cache-control: no-cache" --body-file="${FILE}" "${URL}" > /dev/null } +# Handle preemption gracefully. +function sigterm_handler { + echo -e "\nThis job just got preempted. No worries, it should restart soon.\n" | tee -a $REPORT + echo -n "EndDate: " | tee -a $REPORT + date --utc --rfc-3339=seconds | tee -a $REPORT + upload_file "${REPORT_UPLOAD_URL}" "${REPORT}" "text/plain;charset=utf-8" + exit 1 +} +trap sigterm_handler SIGTERM + # Upload preliminary report every 30s in the background. ( while true ; do