Skip to content

util/multiprovider: Implement Info#4558

Merged
tonistiigi merged 1 commit intomoby:masterfrom
vvoland:multiprovider-info
Feb 23, 2024
Merged

util/multiprovider: Implement Info#4558
tonistiigi merged 1 commit intomoby:masterfrom
vvoland:multiprovider-info

Conversation

@vvoland
Copy link
Collaborator

@vvoland vvoland commented Jan 15, 2024

client.Export in v2 will need an content.Info implementation.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

@vvoland vvoland force-pushed the multiprovider-info branch from ff8aed0 to 8df0cc3 Compare January 16, 2024 09:31
@vvoland
Copy link
Collaborator Author

vvoland commented Jan 16, 2024

Fixed, thanks for spotting!

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Should we maybe just switch the underlying map to InfoProvider? What would that break? These runtime type checks are easy to miss on future code changes.

@vvoland
Copy link
Collaborator Author

vvoland commented Jan 19, 2024

Not sure if something would break. But that would require changing a bunch of content.Providers across buildkit codebase (possibly breaking the public API?).
I can do that if you want to see how that would look.

@tonistiigi
Copy link
Member

@vvoland I think we should at least try that if we have codepaths that actually call into Info() when Provider is passed. If there is some complicated issue why it doesn't work then we can reconsider. Breaking public Go API (not sure if actual breakage for this would really happen) is not a problem.

@vvoland vvoland force-pushed the multiprovider-info branch 2 times, most recently from 539094d to e3f7093 Compare February 8, 2024 11:23
@vvoland vvoland marked this pull request as draft February 8, 2024 11:24
@vvoland vvoland force-pushed the multiprovider-info branch from e3f7093 to 1cbd233 Compare February 8, 2024 14:46
Copy link
Collaborator Author

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

Looks like this also needs an Info implementation for the remote cache providers, but not all data is available there to construct the full content.Info.

Any idea on these? @tonistiigi @crazy-max

@vvoland vvoland marked this pull request as ready for review February 8, 2024 14:51
@vvoland vvoland force-pushed the multiprovider-info branch from 1cbd233 to 66a524b Compare February 8, 2024 15:14
@vvoland vvoland force-pushed the multiprovider-info branch from 66a524b to 075a022 Compare February 9, 2024 12:38
return &readerAt{Reader: rc, Closer: rc, size: desc.Size}, nil
}

func (p *fetchedProvider) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you check if this was needed for anything actually (apart from places in this PR that use it in cache import where it shouldn't be needed) or can FromFetcher keep returning content.Provider. This returns wrong size so not ideal if it actually gets called.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did check by replacing the Info implementation with a panic and running the buildkit tests. They all passed so I think it's not actually needed.

Also, I just implemented the Info for DescriptorProviderPair instead of doing it for each cache implementation.

@tonistiigi
Copy link
Member

Validate failing with:

------
 > [linux/amd64->freebsd/amd64 golangci-lint 1/1] RUN --mount=target=/go/src/github.com/moby/buildkit     --mount=target=/root/.cache,type=cache,id=lint-cache-default-freebsd/amd64   xx-go --wrap &&   golangci-lint run --build-tags "" &&   touch /golangci-lint.done:
661.7 cache/remotecache/v1/chains.go:130:26: use of `fmt.Errorf` forbidden because "use errors\\.Errorf instead" (forbidigo)
661.7 		return content.Info{}, fmt.Errorf("content not found %s", dgst)
661.7 		                       ^
------

Require base provides to implement both content.InfoReaderProvider.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@AkihiroSuda AkihiroSuda added this to the v0.13.0 milestone Feb 19, 2024

remote.Descriptors = append(remote.Descriptors, descPair.Descriptor)
mp.Add(descPair.Descriptor.Digest, descPair.Provider)
mp.Add(descPair.Descriptor.Digest, descPair)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to #4686 :

The original provider should be passed to the multiprovider without hiding methods with the wrapped struct (DescriptorProviderPair). Or, DescriptorProviderPair should export methods multiprovider relies on ( UnlazySession and SnapshotLabels). If this PR is still needed, I can work on this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Feel free to carry this PR :)

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