Skip to content

Commit 735486f

Browse files
committed
fix(e2e): say when a post-install-prep wait attempt hit its bound
When the outer timeout cut a `kubectl wait` attempt, nothing was printed: `timeout` is silent and kubectl dies on the signal. The timeout line then read "last kubectl error: none", which says the client had nothing to report rather than that it was killed mid-request. The attempt's exit status now names that case. The errors the loop prints also carry the script's prefix. The first NotFound shows up on every green run, since the release appears about a minute in, and without the prefix it reads like a failure when the log is scanned after one. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent c96dcaa commit 735486f

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎hack/e2e-post-install-prep.sh‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,19 @@ wait_for_linstor() {
226226
--request-timeout=10s 2>&1 | tail -n 30 >&2
227227
return 1
228228
fi
229-
if { attempt_err=$(timeout -k 5 $(( remaining + 30 )) \
230-
kubectl wait "$@" --timeout="${remaining}s" 2>&1 >&3); } 3>&1; then
229+
attempt_rc=0
230+
{ attempt_err=$(timeout -k 5 $(( remaining + 30 )) \
231+
kubectl wait "$@" --timeout="${remaining}s" 2>&1 >&3); } 3>&1 || attempt_rc=$?
232+
if [ "$attempt_rc" -eq 0 ]; then
231233
return 0
232234
fi
235+
# A bound that fires leaves no text: `timeout` prints nothing and kubectl
236+
# dies on the signal. Not a remote exit code here, so 137 is the -k kill.
237+
case $attempt_rc in
238+
124 | 137) attempt_err="attempt cut by its outer bound after $(( remaining + 30 ))s" ;;
239+
esac
233240
if [ -n "$attempt_err" ] && [ "$attempt_err" != "$last_err" ]; then
234-
printf '%s\n' "$attempt_err" >&2
241+
printf '%s\n' "$attempt_err" | sed 's/^/[post-install-prep] /' >&2
235242
last_err=$attempt_err
236243
fi
237244
sleep 5

‎hack/post-install-prep.bats‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ bounded=${STUB_BOUNDED:-}
104104
[ -n "$bounded" ] || printf 'UNBOUNDED %s\n' "$*" >> "$STUB_CALLS"
105105
case "$*" in
106106
'wait helmrelease/linstor '*)
107+
# The outer bound firing: `timeout` prints nothing and kubectl dies on the
108+
# signal before it can, so the status is the only trace. 124 on TERM, 137
109+
# when kubectl ignored it and the -k KILL landed.
110+
if [ -n "${STUB_WAIT_KILLED:-}" ]; then exit "$STUB_WAIT_KILLED"; fi
107111
if [ -n "${STUB_WAIT_ERR:-}" ]; then echo "$STUB_WAIT_ERR" >&2; fi
108112
[ "$STUB_HR_READY_AT" != never ] && [ "$now" -ge "$STUB_HR_READY_AT" ] ;;
109113
'wait deployment/linstor-controller '*)
@@ -378,9 +382,29 @@ run_prep() {
378382
n=$(grep -v 'timed out' "$tmp/err" | grep -c 'not found' || true)
379383
[ "$n" -eq 1 ]
380384
grep 'timed out' "$tmp/err" | grep -q 'not found'
385+
# Printed on every green run too, since the release appears ~70s in, so it
386+
# has to read as this script's progress rather than as a failure.
387+
grep -v 'timed out' "$tmp/err" | grep 'not found' | grep -q '^\[post-install-prep\] '
381388
rm -rf "$tmp"
382389
}
383390

391+
@test "a wait attempt cut by its outer bound says so in the timeout line" {
392+
for code in 124 137; do
393+
tmp=$(mktemp -d)
394+
prep_sandbox "$tmp"
395+
396+
export STUB_WAIT_KILLED=$code
397+
run_prep "$tmp" never 0
398+
unset STUB_WAIT_KILLED
399+
400+
[ "$(cat "$tmp/rc")" -ne 0 ]
401+
# Without this the line reads "last kubectl error: none", which says the
402+
# client had nothing to report, not that it was killed mid-request.
403+
grep 'timed out' "$tmp/err" | grep -q 'cut by its outer bound'
404+
rm -rf "$tmp"
405+
done
406+
}
407+
384408
@test "a linstor HelmRelease timeout names the upstream release that blocks it" {
385409
tmp=$(mktemp -d)
386410
prep_sandbox "$tmp"

0 commit comments

Comments
 (0)