Commit c55facd
authored
transport: retry HTTP 429 (Too Many Requests) (#2301)
Fixes #2111. As filed by knqyf263, 429 responses are never retried by
the default retry transport even though TooManyRequestsErrorCode is
already classified temporary in transport/error.go.
The retry transport in pkg/v1/remote/transport/retry.go short-circuits
on its codes list before consulting Temporary(); since 429 isn't in
defaultRetryStatusCodes, the conversion to a temporary transport.Error
never happens and retry.IsTemporary never gets called.
The fix is symmetric across the two parallel classifications:
* defaultRetryStatusCodes in pkg/v1/remote/options.go now includes
http.StatusTooManyRequests, so the retry transport wraps a 429
response into a temporary *transport.Error and retries it through
the existing backoff (Duration 1s, Factor 3, Steps 3).
* temporaryStatusCodes in pkg/v1/remote/transport/error.go also
gains http.StatusTooManyRequests, bringing the raw-status fallback
path into alignment with temporaryErrorCodes which has already
been classifying TooManyRequestsErrorCode as temporary.
The exhausted *transport.Error still carries StatusCode == 429, so
pkg/gcrane/copy.go's hasStatusCode helper continues to route 429s
through GCRBackoff at the application layer. The two retry layers
compose: ~1.3s of transport-level retry per request, then ~6s+ of
copy-level retry per image. No existing test expectations change.
Out of scope here: honoring the Retry-After response header. The retry
backoff is currently static; honoring server-dictated delays would
need plumbing through the retry/wait package. Worth a follow-up.
Tests:
* pkg/v1/remote/transport/retry_test.go gains
TestRetryTransport_TooManyRequests, which exercises three 429s
through the retry transport and asserts both that all three
attempts are made and that the final response surfaces with
StatusCode == 429 (so gcrane's hasStatusCode keeps matching).
It also pins the new entry in temporaryStatusCodes.
* pkg/v1/remote/options_test.go (new file) pins 429 in the default
retry status code list. A future refactor that drops 429 will
fail loudly before the regression ships.
Verified locally:
go test ./... (full suite green)
gofmt + goimports clean
golangci-lint v2.11: 0 issues
woke clean on touched files
reviewdog/action-misspell US: clean on the diff1 parent 68a569e commit c55facd
4 files changed
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 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 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
145 | 196 | | |
146 | 197 | | |
147 | 198 | | |
| |||
0 commit comments