Skip to content

Update to BuildKit 0.12#45966

Merged
thaJeztah merged 11 commits intomoby:masterfrom
neersighted:buildkit_0.12
Sep 22, 2023
Merged

Update to BuildKit 0.12#45966
thaJeztah merged 11 commits intomoby:masterfrom
neersighted:buildkit_0.12

Conversation

@neersighted
Copy link
Member

@neersighted neersighted commented Jul 13, 2023

- What I did
Update containerd (library) to v1.7 and BuildKit to v0.12.

Make changes to the code to adjust to the new dependency versions, and fix some TODOs that were waiting on these updates. Leave some new TODOs as well, mostly related to the builder-next code and having to re-implement some things instead of re-using them from BuildKit.

- How I did it
With help from my IDE, and with assistance from others (@tonistiigi, @crazy-max, @rumpl) where I ran out of skill and/or time.

- How to verify it
CI ✅

- Description for the changelog

  • Update buildkit to v0.12.2.
  • Update containerd to v1.7.6.

- A picture of a cute animal (not mandatory but encouraged)

@neersighted

This comment was marked as outdated.

@thaJeztah

This comment was marked as outdated.

@neersighted

This comment was marked as outdated.

@neersighted

This comment was marked as outdated.

Comment on lines +30 to +31
exporterAttrs[string(exptypes.OptKeyName)] = strings.Join(reposAndTags, ",")
exporterAttrs[string(exptypes.OptKeyUnpack)] = "true"
Copy link
Member

Choose a reason for hiding this comment

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

For these I was wondering if it's possible to do the reverse (cast to ImageExporterOptKey) ? Haven't looked at this code locally though, just through GitHub's ui

Copy link
Member Author

Choose a reason for hiding this comment

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

The type in the protobuf is string; I don't know that we can control the codegen enough to "do the right thing" here, and this is the pattern BK uses. Still, it's really clunky, and if we can invert it I'm totally in favor.

Copy link
Member

Choose a reason for hiding this comment

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

Ah... gotcha.. didn't realise we're dealing with protobuf here. Was mostly hoping "strong(ish) types" to help discoverability.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is just a newtype to ease discoverability, but it doesn't seem to be totally ergonomic even on the BK side due to protobufs:
https://github.com/moby/buildkit/blob/f53c1752113e1f9c0fbcc1d5c8e18a9b13452afc/control/control.go#L334-L342

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @crazy-max @jedevc if this is something we can change

Copy link
Member

@crazy-max crazy-max Jul 20, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Maybe map<string, google.protobuf.Any> would have work but the contract is already there.

Copy link
Member Author

@neersighted neersighted Jul 20, 2023

Choose a reason for hiding this comment

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

Right, my thought (and specific inexperience) is that maybe we can change the protobuf definition to use the newtype, and existing clients with the old generated code will continue to interoperate as it's just a type alias to string. That breaks the Go API a little; but in theory the protobuf is the stable component and the generated Go code can change (ala containerd v1.7).

Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out this is not possible as we have multiple types for the keys (ExporterOptKey for all exporters, ImageExporterOptKey for the image exporter).

It looks like this is a wart we'll have to live with; in the future when/if we remove Gogo, the SDK will have to change a fair bit anyway; at that point defining some conversion helper (maybe with generics) ought to be better.

@neersighted neersighted force-pushed the buildkit_0.12 branch 2 times, most recently from 1c661c8 to 21288ba Compare July 20, 2023 14:29
@neersighted neersighted force-pushed the buildkit_0.12 branch 3 times, most recently from b1572f3 to 5e9a6ee Compare September 21, 2023 19:15
neersighted and others added 9 commits September 21, 2023 14:18
The current executor is only tested on Linux, so let's be honest about
that. Stubbing this correctly helps avoid incorrectly trying to call
into Linux-only code in e.g. libnetwork.

Signed-off-by: Bjorn Neergaard <[email protected]>
The DeepEqual ignore required in the daemon tests is a bit ugly, but it
works given the new protoc output.

We also have to ignore lints related to schema1 deprecations; these do
not apply as we must continue to support this schema version.

Signed-off-by: Bjorn Neergaard <[email protected]>
The following changes were required:
* integration/build: progressui's signature changed in moby/buildkit@6b8fbed
* builder-next: flightcontrol.Group has become a generic type in moby/buildkit@8ffc03b
* builder-next/executor: add github.com/moby/buildkit/executor/resources types, necessitated by moby/buildkit@6e87e4b
* builder-next: stub util/network/Namespace.Sample(), necessitated by moby/buildkit@963f161

Co-authored-by: CrazyMax <[email protected]>
Co-authored-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
With BuildKit 0.12, some existing types are now required to be wrapped
by new types:

* containerd's LeaseManager and ContentStore have to be a
  (namespace-aware) BuildKit type since moby/buildkit@f044e0a
* BuildKit's solver.CacheManager is used instead of
  bboltstorage.CacheKeyStorage since moby/buildkit@2b30693
* The MaxAge config field is a bkconfig.Duration since moby/buildkit@e06c962

Signed-off-by: Bjorn Neergaard <[email protected]>
SourcePolicy was accounted for in moby/buildkit@330cf7a

TODO: replace applySourcePolicies with BuildKit's implementation, which
is currently unexported.

Co-authored-by: Tonis Tiigi <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
Introduced years ago in moby/buildkit@6644e1b

Signed-off-by: Bjorn Neergaard <[email protected]>
Now that this is a generic, we can define a struct type at the package
level, and remove the casting logic necessary when we had to use
interface{}.

Signed-off-by: Bjorn Neergaard <[email protected]>
This exposes `ACTIONS_RUNTIME_TOKEN` and `ACTIONS_CACHE_URL`, which are
used to skip cache exporter tests, when combined with
moby/buildkit@a8789cb

Co-authored-by: Bjorn Neergaard <[email protected]>
Signed-off-by: CrazyMax <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Skipping digest-related tests is no longer necessary after containerd/containerd@4065831

Signed-off-by: CrazyMax <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
@thaJeztah thaJeztah merged commit 3614749 into moby:master Sep 22, 2023
@neersighted neersighted deleted the buildkit_0.12 branch September 22, 2023 01:42
)

type Result[T any] struct {
type Result[T comparable] struct {
Copy link
Member

Choose a reason for hiding this comment

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

# github.com/moby/buildkit/frontend/gateway/client
vendor/github.com/moby/buildkit/frontend/gateway/client/client.go:18:29: Reference does not implement comparable
note: module requires Go 1.20

If we want to keep this change, we should update vendor.mod to go 1.20, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, good catch! I should have tested with an older Go compiler.

Copy link
Member

Choose a reason for hiding this comment

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

I guess that's #46069 👀

Copy link
Member

Choose a reason for hiding this comment

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

Oh, nope, that doesn't touch the go line 😅

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes, I decided not to force go1.21 in that PR (as most of the code definitely would still work on older versions); perhaps we still should? At least setting the go.mod to go1.20 could be reasonable I guess. (with go1.19 being EOL); at least for the master / v25.0-dev branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was planning on a follow-up PR (as I have some plans for the go line after Go 1.21), but I think that adding a go 1.20 line to your PR makes some sense 👍

Copy link
Member

Choose a reason for hiding this comment

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

I'll make it a separate commit, as we don't need it for the 24.0 (and other branches)

I guess in that case we might as well make it a separate PR; want to open one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/builder/buildkit Build area/builder Build containerd-integration Issues and PRs related to containerd integration impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/4-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.