-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry on conflicts when generating a random image name #3639
Conversation
... just to eliminate the possibility of failure. Signed-off-by: Miloslav Trmač <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mtrmac The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fair point, I should actually write a test for the name collision check at least. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a race between checking if the name is free and creating the image with this specific name. We recently had a similar issue in Podman when assigning random names to containers.
Oops, you’re right, this is racy anyway; we would need to pre-allocate the name in a way that persistently records that cross-process, which this code does not do. So, this would make the race smaller but not actually eliminate it, just adding false sense of security and potentially confusing readers of this code. Let’s not do that. I don’t see how to truly fix this at this point, so I guess we’ll have to hope the 256-bit ID namespace is large enough :) |
Maybe we can find a similar solution here. What happened in Podman is loop around But I am not sure if that would work with images. |
It probably would work, it’s just so ugly and expensive. (We create the image with a deterministic ID, typically using the config digest; all of that would succeed, only a final |
Strictly speaking the user owns the namespace, so a collision is always possible. Pragmatically, maybe some combination of (container ID, timestamp) could be unique enough. But then the current code uses 256 bits of true randomness (unlike most of Podman, which uses the deterministic PRNG), which is at least as unique. |
What type of PR is this?
What this PR does / why we need it:
Eliminate the risk of possibly generating a conflicting image name.
How to verify it
No non-invasive way.
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
Does this PR introduce a user-facing change?