Commit 61df625
authored
Bound the GitHub client retries so rate limits fail fast (#8506)
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0)
(oldest at bottom):
* #8568
* #8508
* #8507
* __->__ #8506
* #8505
**Impact:** greenlight scan, fingerprint, and verdict paths (the GitHub
client)
**Risk:** low
## What
Wire a bounded plain `urllib3` `Retry` into `build_client`: 5xx-only
forcelist
(403/429 excluded), `respect_retry_after_header=False`, idempotent
methods only
(`GET`/`HEAD`/`PUT`/`DELETE`), `total=2`.
## Why
PyGithub's default `GithubRetry` force-lists 403 and sleeps in-call
until the
rate-limit reset (up to ~1h, unclampable by config), on fingerprint
worker
threads the main-thread SIGALRM timeout cannot interrupt -- so a single
scan
iteration could stall past the runtime budget and be force-killed
(daemon
watchdog / Lambda timeout). A 5xx-only retry that never honors
`Retry-After`
lets a rate limit raise immediately, so the pass is abandoned through
the
existing exception flow instead of hanging.
# Notes
Not retrying `POST`/`PATCH` also removes a latent double-review /
double-dispatch
hazard from the old default. Retry semantics are asserted in new
`test_github_client.py` cases, including that the type is a plain
`urllib3.Retry`
(not `GithubRetry`) and that 403/429 are excluded from the forcelist.
Signed-off-by: Jean Schmidt <contato@jschmidt.me>1 parent c5127d1 commit 61df625
2 files changed
Lines changed: 70 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
52 | 74 | | |
53 | 75 | | |
54 | 76 | | |
55 | 77 | | |
56 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
57 | 85 | | |
58 | 86 | | |
59 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
368 | 409 | | |
369 | 410 | | |
370 | 411 | | |
| |||
0 commit comments