Skip to content

Commit 65889b6

Browse files
committed
fix(e2e): capture ghcr-mirror probe inside if so dash errexit does not abort
The chainsaw kubernetes suites run this helper under `sh -c` with `set -eu`, and dash inherits errexit into command substitutions. A bare `out=$(kubectl get deploy ...); rc=$?` therefore aborts the whole script the moment kubectl exits non-zero (NotFound or a transient error), so neither fallback branch runs and the suite hard-fails at tenant CR creation instead of pulling ghcr.io directly, inverting the helper's 'can only help, never make CI worse' contract. bash does not inherit errexit into $(), which is why it survived local (bash) runs. Capture inside `if out=$(...); then rc=0; else rc=$?; fi` (the form talos-image-cache.sh already uses). Refs #3513 Signed-off-by: IvanHunters <[email protected]>
1 parent 2692c49 commit 65889b6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎hack/e2e-chainsaw/_lib/ghcr-mirror.sh‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ resolve_ghcr_mirror_endpoint() {
5353
# split: a genuine NotFound is a stable decision worth caching, but any other
5454
# failure (transient apiserver blip) must NOT be cached, or one blip would
5555
# disable the mirror for every later test in the shared sandbox.
56-
out=$(kubectl -n kube-system get deploy ghcr-mirror 2>&1); rc=$?
56+
#
57+
# Capture inside `if` (not a bare `out=$(...); rc=$?`): the chainsaw suites run
58+
# this script under `sh -c` with `set -eu`, and dash inherits errexit into a
59+
# command substitution, so a non-zero kubectl in a bare assignment would kill
60+
# the script before either fallback branch runs. bash does not inherit it,
61+
# which is why a bare assignment survives locally but not in CI.
62+
if out=$(kubectl -n kube-system get deploy ghcr-mirror 2>&1); then
63+
rc=0
64+
else
65+
rc=$?
66+
fi
5767
if [ "$rc" -ne 0 ]; then
5868
case "$out" in
5969
*NotFound*|*"not found"*)

0 commit comments

Comments
 (0)