← Back to Pull requests

rekor: Support retries and handle 409 #1970

Closed
unknown closed this pull request without merging on Nov 10, 2026 15:51 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 11:06 UTC
Author

Support Rekor retries (and handle 409s) by switching to urllib3

I believe this is ready for review. It basically replaces #1653 which has bitrotted a bit (although does not replace it completely: fulcio, oidc and tsa still need to be handled in followup). I believe my work also handles the multi-threading signing a bit better.

There are some risks:
We're touching multi-threaded signing and http error handling: both tricky to test in CI or even manually
Switching http provider has some intrinsic risks: things are going to change a bit whatever we do (see TLS certs, proxy variables mentioned below)

I've tested this with excessive amounts of manual signing: things seem to work as expected -- I can't reproduce the typical 503 situation on staging (as I hit a 429 far before that) but I'm pretty confident any normal usage (<100 artifacts at a time) is fully working.

TMPDIR=$(mktemp -d)
for i in $(seq 1 200); do   echo "test artifact $i - $(date +%s%N)" > "$TMPDIR/file_$i.txt"; done
time uv run sigstore -v --staging sign --rekor-version 1 --overwrite "$TMPDIR"/file_*.txt
time uv run sigstore -v --staging sign --rekor-version 2 --overwrite "$TMPDIR"/file_*.txt

This could help with https://github.com/pypa/gh-action-pypi-publish/issues/364

Background

The typical failure mode when Rekor is getting too many requests is:
1. POST request is made when rekor is under high load
2. after 30 seconds the GCP load balancer decides rekor is not answering: client gets 502 response -- in reality rekor/trillian is still working
3. At some point rekor does create the entry
4. If client makes the request again, rekor responds with 409 with the entry uuid

Current sigstore-python stops at step 2. Multiple other clients have higher success rates because they retry.

Fix

The only thing the client can do is retries:
Start using urllib3: this gives us built-in retries (with thread safety)
Do max 2 retries on status code errors and connect errors, with short backoff and some jitter. Use retries on GET and POST on responses 408, 429, 500, 502, 503 and 504 (supporting Retry-After header). Unintuitively retrying after 429 is likely performative -- GCP 429 does not include retry-after and will likely only work after a minute or so -- but the 5xx retries should be practically useful
Set read timeout to 60, do max 1 retry on timeouts (we should not get a client timeout since the service does a 503 earlier)
For rekorv1 handle 409 reponse: do a GET with the entry uuid in that case like sigstore-go does

Notes on regressions / non-features / changed functionality

A change to previous implementation is that non-status errors (connection, DNS, etc) now get wrapped into a RekorClientError as well: this seems reasonable to me.
We still do threaded signing but urllib3 pool is believed to be thread-safe so I removed the thread-local variables from clients. The PoolManagers are configured with maxsize=32 to ensure we can reuse connections as much as the caller decides to multi-thread
proxy env variables are not supported in urllib3 -- we could handle them (there's a small class in python-tuf we could copy but I did not do it now)
rekor now uses different source for TLS certs than rest of sigstore-python (system certs vs certifi): This is non-optimal so we should aim to port oidc, fulcio and timestamp clients over soon as well. I can handle that after this PR

Diff: 428 lines (+321 / -107) across 5 files Reviewer: woodruffw Review duration: 1725m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 428 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.363
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1970"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 45.1% (MEDIUM) · Higher = larger blast radius
45.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.8% · Safe to merge
17.8%