Skip to content

Commit

Permalink
Allow some images test-timestamp updates to fail
Browse files Browse the repository at this point in the history
Normally (in other CI systems) we want to know immediately if updating
timestamps fails.  Otherwise an image could be pruned due to old-age
without anybody noticing.  However on this specific repository, it's
possible that not all images are actually built.  So it's necessary
to allow for some (possibly all) to fail.  However, this shouldn't
impact the testing of the `imgts` container & scripts in CI (here).

Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Jul 1, 2022
1 parent 267c81e commit 68a26cc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ imgts_task:
cpu: 2
memory: '2G'
env:
# Not all $IMGNAMES may have been built, don't fail if some are missing
REQUIRE_ALL: 0 # This should ONLY be set `0` on this repository!
BUILDID: "$CIRRUS_BUILD_ID"
REPOREF: "$CIRRUS_REPO_NAME"
GCPJSON: ENCRYPTED[112c55192dba9a7edd1889a7e704aa1e6ae40730b97ad8ebcbae2bb5f4ff84c7e9ca5b955baaf1f69e7b9e5c5a14a4d3]
Expand Down
10 changes: 8 additions & 2 deletions imgts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ ARGS="
[[ -n "$IMGNAMES" ]] || \
die 1 "No \$IMGNAMES were specified."

# Under some runtime conditions, not all images may be available
REQUIRE_ALL=${REQUIRE_ALL:-1}

# Don't allow one bad apple to ruin the whole batch
ERRIMGS=''

Expand All @@ -53,5 +56,8 @@ do
fi
done

[[ -z "$ERRIMGS" ]] || \
die 2 "ERROR: Failed to update one or more image timestamps: $ERRIMGS"
if [[ -n "$ERRIMGS" ]]; then
die_or_warn=die
((REQUIRE_ALL)) || die_or_warn=warn
$die_or_warn 2 "Failed to update one or more image timestamps: $ERRIMGS"
fi
9 changes: 9 additions & 0 deletions imgts/lib_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ die() {
exit "$EXIT"
}

# Similar to die() but it ignores the first parameter (exit code)
# to allow direct use in place of an (otherwise) die() call.
warn() {
IGNORE=$1
shift
MSG="$*"
echo -e "${RED}WARNING: $MSG${NOR}"
}

# Hilight messages not coming from a shell command
msg() {
echo -e "${YEL}${1:-NoMessageGiven}${NOR}"
Expand Down

0 comments on commit 68a26cc

Please sign in to comment.