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

use c/image/pkg/blobcache #3795

Merged
merged 2 commits into from Mar 2, 2022
Merged

Conversation

vrothberg
Copy link
Member

@vrothberg vrothberg commented Feb 22, 2022

Buildah's pkg/blobcache has been moved into containers/image to
consolidate implementations of interfaces such as image destinations
and image sources.

Create a type alias in pkg/buildcache and redirect NewBlobCache to the
containers/image function. While it is still an API break as it changes
an interface to a struct, known callers will continue building since
they are not implementing the interface.

Since there are no functional changes: [NO NEW TESTS NEEDED]

[1] containers/image#1459

Signed-off-by: Valentin Rothberg vrothberg@redhat.com

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 22, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vrothberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nalind
Copy link
Member

nalind commented Feb 22, 2022

Any reason to not wait until it's in an actually-tagged release of the image library? Please add a type alias and NewBlobCache() wrapper.

@vrothberg
Copy link
Member Author

Any reason to not wait until it's in an actually-tagged release of the image library?

My memory is still fresh on it, and I fear we'd forget about it.

Please add a type alias and NewBlobCache() wrapper.

Note that the BlobCache in c/image is a struct, not an interface. It should compile just fine but strictly speaking it's an API break. Still cool with it?

@nalind
Copy link
Member

nalind commented Feb 22, 2022

Dependabot will catch it. Does the struct not implement the interface?

func cacheLookupReferenceFunc(directory string, compress types.LayerCompression) libimage.LookupReferenceFunc {
// NOTE: this prevents us from moving BlobCache around and generalizes
// the libimage API.
return func(ref types.ImageReference) (types.ImageReference, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Return ref if directory is empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dependabot will catch it.

I am more afraid of forgetting about the manual work to update the code to use the new package.

Does the struct not implement the interface?

The ClearCache was made private but I think we can make it public again. @mtrmac are you cool with that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Return ref if directory is empty.

BTW that could simplify the callers.

func cacheLookupReferenceFunc(directory string, compress types.LayerCompression) libimage.LookupReferenceFunc {
// NOTE: this prevents us from moving BlobCache around and generalizes
// the libimage API.
return func(ref types.ImageReference) (types.ImageReference, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Return ref if directory is empty.

BTW that could simplify the callers.

push.go Outdated Show resolved Hide resolved
@mtrmac
Copy link
Collaborator

mtrmac commented Feb 22, 2022

Please add a type alias and NewBlobCache() wrapper.

(Thinking about the ClearCache method, and to minimize round-trips) Is the goal to keep the Go-visible API surface stable (i.e. caring about the struct/interface distinction), as a matter of policy/principle (similar to c/image), or to keep a specific external consumer working (without caring about the struct/interface distinction)?

Should the existing Buildah callers use Buildah’s wrapper, or call the c/image version directly?


The ClearCache was made private but I think we can make it public again. @mtrmac are you cool with that?

Yes; I can’t see a strong reason not to expose that.

vrothberg added a commit to vrothberg/image that referenced this pull request Feb 22, 2022
To allow for callers of Buildah's pkg/blobcache to continue building [1].

[1] containers/buildah#3795 (comment)

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@nalind
Copy link
Member

nalind commented Feb 22, 2022

We're a library, so it's supposed to be a principle that we compromise on only rarely and with care. Historically, not everyone agrees with that, and I make mistakes, too.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 22, 2022

We're a library, so it's supposed to be a principle that we compromise on only rarely and with care.

Makes sense, thanks.

@vrothberg
Copy link
Member Author

Repushed with a type alias and forwarding of NewBlobCache to c/image.

@vrothberg
Copy link
Member Author

@nalind @mtrmac PTAL

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.

Implementation mechanism LGTM. I understood the discussion to mean that Buildah’s type should remain an interface — up to @nalind .

@vrothberg
Copy link
Member Author

Implementation mechanism LGTM. I understood the discussion to mean that Buildah’s type should remain an interface — up to @nalind .

Let's do that.

@TomSweeneyRedHat
Copy link
Member

LGTM
but definitely want a @nalind head nod

@nalind
Copy link
Member

nalind commented Feb 28, 2022

Implementation looks fine, but again, I'd rather we wait until this is in an actual release of the image library.

@mtrmac
Copy link
Collaborator

mtrmac commented Mar 1, 2022

I'd rather we wait until this is in an actual release of the image library.

Let’s do that: containers/image#1482 .

@mtrmac
Copy link
Collaborator

mtrmac commented Mar 1, 2022

@vrothberg c/image 5.20.0 has been released.

@vrothberg
Copy link
Member Author

To be frank, I don't think it's a good policy to only merge c/image if there's a release. We don't do it for c/storage either and it's slowing down development.

@vrothberg
Copy link
Member Author

@vrothberg c/image 5.20.0 has been released.

Thanks for taking care!

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Buildah's pkg/blobcache has been moved into containers/image [1] to
consolidate implementations of interfaces such as image destinations
and image sources.

Since there are no functional changes: [NO NEW TESTS NEEDED]

[1] containers/image#1459

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Mar 2, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Mar 2, 2022
@openshift-merge-robot openshift-merge-robot merged commit a661629 into containers:main Mar 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants