Skip to content

Only rate limit ACR referrer lookup requests - #2143

Merged
lbussell merged 7 commits into
mainfrom
issue-2141
Jun 17, 2026
Merged

lbussell merged 7 commits into
mainfrom
issue-2141

Conversation

@lbussell

Copy link
Copy Markdown
Member

This PR fixes #2141. The issue text contains the detailed explanation of why these changes are necessary, but summarizing here:

@lbussell
lbussell requested a review from a team as a code owner June 12, 2026 21:01
@lbussell

Copy link
Copy Markdown
Member Author

Current code has a problem where unbounded concurrency sends too many oauth requests to the registry up-front during image copying, causing more 429 errors. The default HTTP client has retries enabled, but oauth requests are POST requests, so they aren't retried. I will have a fix for this pushed shortly.

CancellationToken cancellationToken)
{
Interlocked.Increment(ref _requestCount);
return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
Comment on lines +156 to +158
catch (Exception exception) when (exception is ArgumentException or SecurityTokenMalformedException)
{
}
@lbussell
lbussell requested a review from mthalman June 17, 2026 15:45
@lbussell

lbussell commented Jun 17, 2026 •

Copy link
Copy Markdown
Member Author

I tested this internally with a publish run of the dotnet-docker pipeline: build#3002401

Here are some metrics from that run:

Metric Value
Copy Images task duration 470.7 s (~7.85 min)
Active request window 372.6 s
Tags to copy/import 1,706

Requests/responses by endpoint:

Endpoint / layer Total Success 401 429 Retries Avg req/60s Peak req/60s
manifests (HEAD) 3,412 1,706 1,706 0 0 551 3,412
oauth2/token 2,151 1,706 0 445 445 347 2,151
referrers (GET) 1,706 1,706 0 0 0 275 500
ImportImage (ARM) 1,807 1,706 — 101 101 285 500
Total 9,076 6,824 1,706 546 546 — —

The high number of 401 responses is normal. ORAS only tries to get a token for the registry if it gets a 401 first.

429 responses for oauth requests still happen due to unbounded parallelism, but now they are correctly handled by the Azure SDK.

If we see further issues or failures, then we can revisit bounded parallelism with higher limits.

The high number of oauth token requests is not expected, so I'm investigating.

@lbussell
lbussell enabled auto-merge (squash) June 17, 2026 18:56
@lbussell
lbussell merged commit 518baf2 into main Jun 17, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copying images during publishing is extremely slow

2 participants