Commit 8af8f69
committed
Stop the VCP e2e test hanging when the certificate never appears
Run 34356382122 sat on a single step for 50 minutes and had to be
cancelled by hand. It would otherwise have held a GKE cluster until the
default six hour job timeout. A healthy run takes about 14 minutes.
The cause is the final wait in hack/e2e/test.sh:
for ((i=0;;i++)); do if getCertificate; then exit 0; fi; sleep 30; done \
| timeout -v -- 5m cat
`timeout` bounds `cat`, not the loop. While getCertificate is failing it
writes nothing to the pipe, so it never takes a SIGPIPE. When `timeout`
kills `cat` at five minutes, Bash blocks forever waiting for the loop
subshell, which is still going. The `exit 0` on success only leaves that
subshell, so it cannot end the script either.
The logs of the cancelled run show how bad this gets. `cat` was killed at
13:33:54. The loop then polled a dead pipe for another seventeen minutes.
At 13:50:36 the output changed to "jq: error: writing output failed:
Broken pipe", which is the branch jq only reaches when count is non-zero.
The certificate had arrived and the test could no longer observe it.
Replace the pipeline with a plain deadline loop, so the wait fails at five
minutes with a message naming the certificate it gave up on.
Bound the poll itself as well. getCertificate's curl had no time limit, and
the deadline is only checked after a poll returns, so a connection that
stalls once accepted would hang inside the poll and never reach the check —
the same class of hang, moved from the loop into the request. Confirmed
against a server that accepts and then sends nothing: bare `curl -fsSL` had
to be killed from outside after 45s, while `--max-time 10` returned on its
own with exit 28. curl's 300s default connect timeout does not help, since
it already exceeds the budget and does not apply once the connection is up.
Also apply the same reasoning to the log wait above it. That one worked,
but only because kubectl keeps writing and so does take a SIGPIPE, which
is why it needed `set +o pipefail` around it. hack/ark/test-e2e.sh and
hack/ngts/test-e2e.sh already solve this properly by passing the stream in
by process substitution and letting `timeout` bound jq itself. Use that
form here too and drop the pipefail dance.
Finally, give the three e2e jobs a timeout-minutes. They had none, so the
default six hours applied. This is a backstop, not a fix: the script
should fail on its own, and a job that holds a GKE cluster should not be
able to run for six hours if it does not.
Two things this does not address, both worth their own change:
- The certificate took about 22 minutes to appear in the inventory. The
five minute budget is unchanged here, so this run would still have
failed, just promptly and with a clear message.
- Each run leaks two Venafi service accounts, the registry one created
around line 90 and the agent one created in the unbounded `while true`
loop around line 140. Nothing deletes them. That loop has no sleep, so
if it ever fails to converge it will hammer the API. The other curls in
the script are likewise unbounded.
Tested by extracting both wait constructs into harnesses and running them
against a stream that succeeds and one that never does. The old loop had
to be killed from outside and exited 124; the replacement exits 1 at the
deadline and still exits 0 on success. The new log wait exits 0 on match
and 124 on timeout.
Signed-off-by: Richard Wall <richard.wall@cyberark.com>1 parent 7e728f6 commit 8af8f69
2 files changed
Lines changed: 30 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
205 | 204 | | |
206 | 205 | | |
207 | 206 | | |
| |||
210 | 209 | | |
211 | 210 | | |
212 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
| |||
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
| 231 | + | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
235 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
0 commit comments