Skip to content
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

storage.storageImageDestination.Commit(): leverage image options #2067

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

nalind
Copy link
Member

@nalind nalind commented Aug 1, 2023

When committing an image, pass big data items and the image metadata string in as part of the set of options we pass to the storage library when creating the image.

Fall back to setting them individually, as we would have originally, only if we end up updating an image that was already in local storage.

@nalind nalind force-pushed the create-image-options branch from 3c47e19 to 6186aa7 Compare August 1, 2023 21:58
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks, this is a great improvement, both in correctness and efficiency.


Compare containers/storage#595 — from a quick check this seems to be a major improvement in that problem space, but maybe we should order the “big data” items in a specific order (config, individual manifest, top-level manifest; what about signatures?!) to avoid the remaining races.

storage/storage_dest.go Outdated Show resolved Hide resolved
storage/storage_dest.go Outdated Show resolved Hide resolved
storage/storage_dest.go Outdated Show resolved Hide resolved
storage/storage_dest.go Outdated Show resolved Hide resolved
storage/storage_dest.go Outdated Show resolved Hide resolved
}
}()

// Add the reference's name on the image. We don't need to worry about avoiding duplicate
// values because AddNames() will deduplicate the list that we pass to it.
if name := s.imageRef.DockerReference(); name != nil {
if err := s.imageRef.transport.store.AddNames(img.ID, []string{name.String()}); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can also be done using a parameter to CreateImage if the image does not exist yet; that would avoid another trip through the fairly costly locking implementation.


… and then we would really need the commitSucceeded handling only in the “image already exists” case, and that would be an opportunity revisit whether we really want to delete the image, or maybe we can just delete that code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Some care has to be taken with that parameter - if any of the names passed at create-time are already in use, we get an ErrDuplicateName error back, and I think we want to avoid that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops, I didn’t notice that CreateImage returns ErrDuplicateName.

It might make sense to let callers opt in into overriding names with a new field in storage.ImageOptions, but that would not be quite an one-line change, so let’s not wait on that.

@vrothberg
Copy link
Member

Can we do test-vendor PRs in Buildah and Podman before merging?

@nalind nalind force-pushed the create-image-options branch from 6186aa7 to f268b8e Compare August 4, 2023 18:24
When committing an image, pass big data items and the image metadata
string in as part of the set of options we pass to the storage library
when creating the image.

Fall back to setting them individually, as we would have originally,
only if we end up updating an image that was already in local storage.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
@nalind nalind force-pushed the create-image-options branch from f268b8e to 4f1bcfb Compare August 4, 2023 20:54
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

Valentin asked for test-vendor PRs, that seems to be a reasonable precaution to me.

@TomSweeneyRedHat
Copy link
Member

LGTM once the Buildah/Podman tests run.

rhatdan added a commit to rhatdan/podman that referenced this pull request Aug 5, 2023
containers/image#2067

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM
containers/podman#19525 is green

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.

5 participants