Skip to content

Conversation

@mtrmac
Copy link
Contributor

@mtrmac mtrmac commented Oct 23, 2025

Currently, on pushes, we can start several concurrent layer pushes; each one will check for a bearer token in tokenCache, find none, and ask the server for one, and then write it into the cache.

So, we can hammer the server with 6 basically-concurrent token requests. That's unnecessary, slower than just asking once, and potentially might impact rate limiting heuristics.

Instead, serialize writes to a bearerToken so that we only have one request in flight at a time.

This does not benefit pulls, where the first request is for a manifest, which obtains a token, so subsequent concurrent layer pulls will not request a token again.

See individual commit messages for details.

(This continues, and updates, containers/image#1968 .)

@github-actions github-actions bot added the image Related to "image" package label Oct 23, 2025
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Oct 23, 2025
@podmanbot
Copy link

✅ A new PR has been created in buildah to vendor these changes: containers/buildah#6448

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

... because we will make it more complex.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
... to decrease indentation and remove a variable.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
We will want to manage concurrency in more detail.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
We will want to add a lock to it, so we must stop copying it by value.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
Instead of having getBearerToken* construct a new bearerToken
object, have the caller provide one.

This will allow us to record that a token is being obtained,
so that others can wait for it.

Should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
Currently, on pushes, we can start several concurrent layer pushes;
each one will check for a bearer token in tokenCache, find none,
and ask the server for one, and then write it into the cache.

So, we can hammer the server with 6 basically-concurrent token requests.
That's unnecessary, slower than just asking once, and potentially might
impact rate limiting heuristics.

Instead, serialize writes to a bearerToken so that we only have one request in
flight at a time.

This does not benefit pulls, where the first request is for a manifest;
that obtains a token, so subsequent concurrent layer pulls will not request
a token again.

Signed-off-by: Miloslav Trmač <[email protected]>
podmanbot pushed a commit to podmanbot/buildah that referenced this pull request Nov 3, 2025
@mtrmac mtrmac merged commit 0443a77 into containers:main Nov 3, 2025
25 checks passed
@mtrmac mtrmac deleted the shared-token branch November 3, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

image Related to "image" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants