You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
setup-ocp.sh exits 0 after logging '✗ Sandbox pod not Ready' — a failed bring-up reports success #178
→ Waiting for Sandbox sandbox-0 .status.selector, then pod Ready (up to ~2m)...
✗ Sandbox pod not Ready (see /tmp/.../sandbox-wait.log)
NAME READY STATUS RESTARTS AGE
sandbox-0 0/1 ImagePullBackOff 0 3m1s
$ echo$?0
Why it matters
The ✗ is easy to miss in a long bring-up log, and an exit code of 0 makes it invisible to anything automated. Concretely: this is how a completely broken bring-up (no sandbox pods at all, because of #177) was mistaken for a successful one — the script printed the failure, exited clean, and the problem only surfaced later as unexplained behavior further down the workflow.
Anything that scripts this — CI, a demo runner, setup-ocp.sh && next-step — proceeds against a cluster that cannot serve a single sandbox.
Expected
A readiness gate that fails should exit non-zero, so set -e / && chains and CI stop there.
Note on scope
Worth a quick audit of the other ✗/log_error paths in the same script for the same pattern rather than fixing only this one call site — and the same check in setup-k8s.sh / setup-kind.sh, which share the shape.
Found while bringing up a fresh OpenShift 4.20.8 cluster for the remote-sandbox live gate (#176).
Investigated this before changing anything, and I can't reproduce the exit 0 — I believe it's a measurement artifact rather than a script bug. Evidence, then what I did instead.
The gate has always exited non-zero
git log -S 'log_error "Sandbox pod not Ready' returns exactly one commit — cb191209 — and it included exit 1. git show 0e9b9fc:deploy/knative/setup-ocp.sh (main as of this issue's timestamp) has:
|| { log_error "Sandbox pod not Ready (see $LOG_DIR/sandbox-wait.log)"; \
$KUBECTL -n "$NAMESPACE" get pod sandbox-0 -o wide 2>/dev/null ||true;exit 1; }
So the exit 1 was present in the code that produced your log.
Reproducing the construct
I replicated the gate verbatim under set -euo pipefail with a stub $KUBECTL whose wait fails:
Invocation
Exit
bash gate.sh
1
bash gate.sh 2>&1 | tee log
0 — a pipeline reports its last command
bash gate.sh; <something>; echo $?
0 — $? is the intervening command's
Entering that \|\| { … } branch always ends in exit 1; it's a brace group, not a subshell, so it can't be swallowed.
The tell in the pasted output
The script prints the table with get pod sandbox-0 -o wide, and -o wide adds IP, NODE, NOMINATED NODE, READINESS GATES. The table in the report has only:
NAME READY STATUS RESTARTS AGE
That's get podwithout-o wide — so it came from a separate manual command run after the script, which makes the echo $? → 0 that command's status. That matches row 3 above.
Audit of the other paths (as suggested)
Did the brace-aware audit across setup-ocp.sh, setup-k8s.sh, and setup-kind.sh: no failure path logs and continues. (My first pass flagged setup-k8s.sh:240, but that was a false positive — its exit 1 is two lines down inside the brace group.)
What was actually wrong
Three things worth fixing that this issue did point at — PR #194:
log_warn/log_error wrote to stdout, unlike setup-k8s.sh. This is exactly why the ✗ is "easy to miss": redirect stdout and the failure vanishes; pipe it and diagnostics interleave with progress. Both now go to stderr, so the error survives >/dev/null.
All 17 readiness gates used cmd && log_success … || { fail } — shellcheck SC2015. That shape runs the failure branch whenever log_success fails, so they reported correctly only because echo returns 0. All 17 are now if/else; shellcheck is clean.
Nothing pinned the exit-code contract — the regression this issue actually feared (a future edit dropping an exit) was unguarded. Added a die() helper, an SH_SOURCE_ONLY hook mirroring setup-kind.sh, and a test that enforces all three invariants across the three scripts. Each assertion was validated against a planted regression.
So the contract you asked for now holds by test instead of by luck. Suggest closing this as not-a-bug once #194 lands.
One knock-on: the "a completely broken bring-up was mistaken for a successful one" note here and in #177 was most likely the same artifact — worth knowing, since it means nothing was silently swallowing failures during that bring-up.
#194 is merged (db29c699). Closing this as not a bug — the reported exit 0 was a measurement artifact, not a script defect. Detail is in the comment above; the short version:
setup-ocp.sh has exited non-zero on that gate since it was written. git log -S finds exactly one commit that ever wrote the line (cb191209), exit 1 included, and it was unchanged at 0e9b9fc — main as of this report. A direct run exits 1; the 0 appears only when the caller drops it (| tee, or reading $? past the script). The pasted pod table gives it away: it lacks the IP/NODE columns that the script's get pod -o wide prints, so it came from a separate manual get pod — and the 0 is that command's status.
What did change
Verified on main after the merge:
Invariant
Status
log_warn + log_error route to stderr
2/2 helpers
die() helper present
yes
SC2015 A && B || C gates remaining
0 (was 17)
setup-script-failure-contract.test.ts
present, 11 cases
So the contract this issue asked for — a readiness failure exits non-zero, loudly — is now enforced by test across setup-ocp.sh, setup-k8s.sh, and setup-kind.sh, rather than holding because echo happens to return 0. A future edit that drops an exit, moves diagnostics back to stdout, or reintroduces the A && B || C shape fails CI.
The concrete usability win is #2 from that list: log_warn/log_error previously went to stdout, which is what made the ✗ easy to miss. An error now survives >/dev/null and stays separable when the bring-up is piped.
Two notes for the record
The scope suggestion here was right to ask for the audit — it's what surfaced the 17 SC2015 gates and the stdout routing, neither of which was the reported symptom.
Reopen if you hit an exit 0 from a direct, unpiped ./deploy/knative/setup-ocp.sh — that would be a different bug from the one described here, and the exact command line would be the thing to capture.
Activity
pdettori commentedon Aug 31, 2026
Investigated this before changing anything, and I can't reproduce the exit 0 — I believe it's a measurement artifact rather than a script bug. Evidence, then what I did instead.
The gate has always exited non-zero
git log -S 'log_error "Sandbox pod not Ready'returns exactly one commit —cb191209— and it includedexit 1.git show 0e9b9fc:deploy/knative/setup-ocp.sh(main as of this issue's timestamp) has:So the
exit 1was present in the code that produced your log.Reproducing the construct
I replicated the gate verbatim under
set -euo pipefailwith a stub$KUBECTLwhosewaitfails:bash gate.shbash gate.sh 2>&1 | tee logbash gate.sh; <something>; echo $?$?is the intervening command'sEntering that
\|\| { … }branch always ends inexit 1; it's a brace group, not a subshell, so it can't be swallowed.The tell in the pasted output
The script prints the table with
get pod sandbox-0 -o wide, and-o wideaddsIP,NODE,NOMINATED NODE,READINESS GATES. The table in the report has only:That's
get podwithout-o wide— so it came from a separate manual command run after the script, which makes theecho $?→0that command's status. That matches row 3 above.Audit of the other paths (as suggested)
Did the brace-aware audit across
setup-ocp.sh,setup-k8s.sh, andsetup-kind.sh: no failure path logs and continues. (My first pass flaggedsetup-k8s.sh:240, but that was a false positive — itsexit 1is two lines down inside the brace group.)What was actually wrong
Three things worth fixing that this issue did point at — PR #194:
log_warn/log_errorwrote to stdout, unlikesetup-k8s.sh. This is exactly why the✗is "easy to miss": redirect stdout and the failure vanishes; pipe it and diagnostics interleave with progress. Both now go to stderr, so the error survives>/dev/null.cmd && log_success … || { fail }— shellcheck SC2015. That shape runs the failure branch wheneverlog_successfails, so they reported correctly only becauseechoreturns 0. All 17 are now if/else; shellcheck is clean.exit) was unguarded. Added adie()helper, anSH_SOURCE_ONLYhook mirroringsetup-kind.sh, and a test that enforces all three invariants across the three scripts. Each assertion was validated against a planted regression.So the contract you asked for now holds by test instead of by luck. Suggest closing this as not-a-bug once #194 lands.
One knock-on: the "a completely broken bring-up was mistaken for a successful one" note here and in #177 was most likely the same artifact — worth knowing, since it means nothing was silently swallowing failures during that bring-up.
fix(deploy/knative): make setup-ocp.sh failures loud and its gates un…
pdettori commentedon Aug 31, 2026
#194 is merged (
db29c699). Closing this as not a bug — the reported exit 0 was a measurement artifact, not a script defect. Detail is in the comment above; the short version:setup-ocp.shhas exited non-zero on that gate since it was written.git log -Sfinds exactly one commit that ever wrote the line (cb191209),exit 1included, and it was unchanged at0e9b9fc— main as of this report. A direct run exits 1; the 0 appears only when the caller drops it (| tee, or reading$?past the script). The pasted pod table gives it away: it lacks theIP/NODEcolumns that the script'sget pod -o wideprints, so it came from a separate manualget pod— and the0is that command's status.What did change
Verified on
mainafter the merge:log_warn+log_errorroute to stderrdie()helper presentA && B || Cgates remainingsetup-script-failure-contract.test.tsSo the contract this issue asked for — a readiness failure exits non-zero, loudly — is now enforced by test across
setup-ocp.sh,setup-k8s.sh, andsetup-kind.sh, rather than holding becauseechohappens to return 0. A future edit that drops anexit, moves diagnostics back to stdout, or reintroduces theA && B || Cshape fails CI.The concrete usability win is #2 from that list:
log_warn/log_errorpreviously went to stdout, which is what made the✗easy to miss. An error now survives>/dev/nulland stays separable when the bring-up is piped.Two notes for the record
Reopen if you hit an exit 0 from a direct, unpiped
./deploy/knative/setup-ocp.sh— that would be a different bug from the one described here, and the exact command line would be the thing to capture.