Commit d9fa833
committed
test(e2e): retry transient network errors on idempotent requests
The TestEGUpgrade teardown intermittently fails with a transient
connection-level error when the gateway-api conformance suite's cleanup
deletes the upgrade GatewayClass:
Delete ".../gatewayclasses/upgrade": EOF
This is a test-infra flake, not a regression in the code under test: it
shows up on unrelated PRs, and the failing DELETE runs in the suite's
registered t.Cleanup after the test body already succeeded.
Root cause: client-go's rest.Request only retries GET on transient
errors (IsProbableEOF/IsConnectionReset/IsHTTP2ConnectionLost); DELETE
and other write verbs surface the error immediately. So when a DELETE
reaches the apiserver but the response is lost (EOF / connection reset /
HTTP/2 GOAWAY / timeout), teardown fails even though the resource was
already deleted.
Fix: install a retrying http.RoundTripper via rest.Config.WrapTransport in
test/utils/kubernetes NewClient. WrapTransport is the only hook inherited
by the conformance suite's per-test client rebuild (setClientsetForTest
calls client.New(suite.RestConfig, ...)), so a client.Client wrapper would
be bypassed while the transport wrapper is not.
Retry policy (conservative):
- Methods: GET, HEAD, DELETE only. Never POST/PATCH/PUT.
- Body: only retry when replayable (nil / http.NoBody / GetBody != nil).
client-go builds DELETE bodies from bytes.NewReader, and the stdlib
auto-populates GetBody for *bytes.Reader, so DeleteOptions bodies are
replayable. http.NoBody must be checked explicitly because the stdlib
substitutes it for a zero-length body instead of nil.
- Before each retry after the first: re-derive the body via GetBody and
assign to a Clone (Clone copies GetBody but does not reset Body).
- Errors retried: EOF, ErrUnexpectedEOF, connection reset, HTTP/2
GOAWAY/connection-lost, net.Error timeouts.
- HTTP status codes are NOT retried (5xx/429/404 returned as-is), so a
404 from a retried DELETE flows through to MustApplyWithCleanup's
existing IsNotFound -> success handling.
- Close any partial resp.Body before retrying; honor context cancellation
in the backoff select.
- Compose with any pre-existing cfg.WrapTransport via transport.Wrappers.
Adds unit tests covering: EOF retry on GET, DELETE-with-body replay via
GetBody, non-retry of POST/non-replayable bodies, non-retry of HTTP
status codes (incl. 404 pass-through), attempt exhaustion, context
cancellation, and timeout (net.Error) retry.
Fixes #9467
Signed-off-by: liuhy <liuhongyu@apache.org>1 parent 69e072f commit d9fa833
2 files changed
Lines changed: 565 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| 17 | + | |
13 | 18 | | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
28 | 51 | | |
29 | 52 | | |
30 | 53 | | |
| |||
42 | 65 | | |
43 | 66 | | |
44 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
0 commit comments