-
Notifications
You must be signed in to change notification settings - Fork 18.9k
vendor: update buildkit to v0.11.2 #44686
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ import ( | |
| "github.com/docker/docker/reference" | ||
| "github.com/moby/buildkit/exporter" | ||
| "github.com/moby/buildkit/exporter/containerimage/exptypes" | ||
| "github.com/moby/buildkit/util/compression" | ||
| "github.com/opencontainers/go-digest" | ||
| "github.com/pkg/errors" | ||
| ) | ||
|
|
@@ -103,22 +102,18 @@ func (e *imageExporterInstance) Name() string { | |
| return "exporting to image" | ||
| } | ||
|
|
||
| func (e *imageExporterInstance) Config() exporter.Config { | ||
| return exporter.Config{ | ||
| Compression: compression.Config{ | ||
| Type: compression.Default, | ||
| }, | ||
| } | ||
| func (e *imageExporterInstance) Config() *exporter.Config { | ||
| return exporter.NewConfig() | ||
| } | ||
|
|
||
| func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source, sessionID string) (map[string]string, error) { | ||
| func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source, sessionID string) (map[string]string, exporter.DescriptorReference, error) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This signature is starting to look a bit awkward; I had a quick look, and it seems this is ultimately defined in the BuildKit repository. As it's being updated already, would it make sense to have a struct definition for the returned values (which contains both the I haven't looked very closely, but the existing return map[string]string{
exptypes.ExporterImageConfigDigestKey: configDigest.String(),
exptypes.ExporterImageDigestKey: id.String(),
}Which feels like it was intended as a "generic" key/value list (maybe I'm wrong though), so perhaps the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are for different use cases. Map is for the client to handle metadata while the new field in for buildkit internal post-processing that runs after the exporter. If there are more fields for post-processing in the future, then the new field should be turned into struct instead of adding a 4th var. |
||
| if len(inp.Refs) > 1 { | ||
| return nil, fmt.Errorf("exporting multiple references to image store is currently unsupported") | ||
| return nil, nil, fmt.Errorf("exporting multiple references to image store is currently unsupported") | ||
| } | ||
|
|
||
| ref := inp.Ref | ||
| if ref != nil && len(inp.Refs) == 1 { | ||
| return nil, fmt.Errorf("invalid exporter input: Ref and Refs are mutually exclusive") | ||
| return nil, nil, fmt.Errorf("invalid exporter input: Ref and Refs are mutually exclusive") | ||
| } | ||
|
|
||
| // only one loop | ||
|
|
@@ -137,14 +132,14 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source, | |
| case 1: | ||
| platformsBytes, ok := inp.Metadata[exptypes.ExporterPlatformsKey] | ||
| if !ok { | ||
| return nil, fmt.Errorf("cannot export image, missing platforms mapping") | ||
| return nil, nil, fmt.Errorf("cannot export image, missing platforms mapping") | ||
| } | ||
| var p exptypes.Platforms | ||
| if err := json.Unmarshal(platformsBytes, &p); err != nil { | ||
| return nil, errors.Wrapf(err, "failed to parse platforms passed to exporter") | ||
| return nil, nil, errors.Wrapf(err, "failed to parse platforms passed to exporter") | ||
| } | ||
| if len(p.Platforms) != len(inp.Refs) { | ||
| return nil, errors.Errorf("number of platforms does not match references %d %d", len(p.Platforms), len(inp.Refs)) | ||
| return nil, nil, errors.Errorf("number of platforms does not match references %d %d", len(p.Platforms), len(inp.Refs)) | ||
| } | ||
| config = inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, p.Platforms[0].ID)] | ||
| if v, ok := inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterBuildInfo, p.Platforms[0].ID)]; ok { | ||
|
|
@@ -157,16 +152,16 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source, | |
| layersDone := oneOffProgress(ctx, "exporting layers") | ||
|
|
||
| if err := ref.Finalize(ctx); err != nil { | ||
| return nil, layersDone(err) | ||
| return nil, nil, layersDone(err) | ||
| } | ||
|
|
||
| if err := ref.Extract(ctx, nil); err != nil { | ||
| return nil, err | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| diffIDs, err := e.opt.Differ.EnsureLayer(ctx, ref.ID()) | ||
| if err != nil { | ||
| return nil, layersDone(err) | ||
| return nil, nil, layersDone(err) | ||
| } | ||
|
|
||
| diffs = make([]digest.Digest, len(diffIDs)) | ||
|
|
@@ -181,36 +176,36 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source, | |
| var err error | ||
| config, err = emptyImageConfig() | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, nil, err | ||
| } | ||
| } | ||
|
|
||
| history, err := parseHistoryFromConfig(config) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| diffs, history = normalizeLayersAndHistory(diffs, history, ref) | ||
|
|
||
| config, err = patchImageConfig(config, diffs, history, inp.Metadata[exptypes.ExporterInlineCache], buildInfo) | ||
| if err != nil { | ||
| return nil, err | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| configDigest := digest.FromBytes(config) | ||
|
|
||
| configDone := oneOffProgress(ctx, fmt.Sprintf("writing image %s", configDigest)) | ||
| id, err := e.opt.ImageStore.Create(config) | ||
| if err != nil { | ||
| return nil, configDone(err) | ||
| return nil, nil, configDone(err) | ||
| } | ||
| _ = configDone(nil) | ||
|
|
||
| if e.opt.ReferenceStore != nil { | ||
| for _, targetName := range e.targetNames { | ||
| tagDone := oneOffProgress(ctx, "naming to "+targetName.String()) | ||
| if err := e.opt.ReferenceStore.AddTag(targetName, digest.Digest(id), true); err != nil { | ||
| return nil, tagDone(err) | ||
| return nil, nil, tagDone(err) | ||
| } | ||
| _ = tagDone(nil) | ||
| } | ||
|
|
@@ -219,5 +214,5 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source, | |
| return map[string]string{ | ||
| exptypes.ExporterImageConfigDigestKey: configDigest.String(), | ||
| exptypes.ExporterImageDigestKey: id.String(), | ||
| }, nil | ||
| }, nil, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |||
|
|
||||
| "github.com/containerd/containerd/content" | ||||
| "github.com/containerd/containerd/images" | ||||
| "github.com/containerd/containerd/leases" | ||||
| "github.com/containerd/containerd/platforms" | ||||
| "github.com/containerd/containerd/rootfs" | ||||
| "github.com/docker/docker/builder/builder-next/adapters/containerimage" | ||||
|
|
@@ -39,13 +40,18 @@ import ( | |||
| "github.com/moby/buildkit/util/compression" | ||||
| "github.com/moby/buildkit/util/contentutil" | ||||
| "github.com/moby/buildkit/util/progress" | ||||
| "github.com/moby/buildkit/version" | ||||
| "github.com/opencontainers/go-digest" | ||||
| ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| "github.com/pkg/errors" | ||||
| "github.com/sirupsen/logrus" | ||||
| "golang.org/x/sync/semaphore" | ||||
| ) | ||||
|
|
||||
| func init() { | ||||
| version.Version = "v0.11.0-rc3" | ||||
| } | ||||
|
|
||||
|
Comment on lines
+51
to
+54
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have a plain
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to set it with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering that indeed; wasn't sure if it would allow setting things in vendor.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine, maybe also add a comment in Line 54 in b9fe30d
to not forget to also update this. |
||||
| const labelCreatedAt = "buildkit/createdat" | ||||
|
|
||||
| // LayerAccess provides access to a moby layer from a snapshot | ||||
|
|
@@ -63,6 +69,7 @@ type Opt struct { | |||
| Snapshotter snapshot.Snapshotter | ||||
| ContentStore content.Store | ||||
| CacheManager cache.Manager | ||||
| LeaseManager leases.Manager | ||||
| ImageSource *containerimage.Source | ||||
| DownloadManager *xfer.LayerDownloadManager | ||||
| V2MetadataService distmetadata.V2MetadataService | ||||
|
|
@@ -157,17 +164,42 @@ func (w *Worker) GCPolicy() []client.PruneInfo { | |||
| return w.Opt.GCPolicy | ||||
| } | ||||
|
|
||||
| // BuildkitVersion returns BuildKit version | ||||
| func (w *Worker) BuildkitVersion() client.BuildkitVersion { | ||||
| return client.BuildkitVersion{ | ||||
| Package: version.Package, | ||||
| Version: version.Version + "-moby", | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still wondering a bit if |
||||
| Revision: version.Revision, | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably needs packaging changes to propagate the version (as the version from the vendored BuildKit code won't be set) 🤔
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hum yes we might need smth like: crazy-max@59746a8
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @crazy-max remind me to this one 😅 |
||||
| } | ||||
| } | ||||
|
|
||||
| // Close closes the worker and releases all resources | ||||
| func (w *Worker) Close() error { | ||||
| return nil | ||||
| } | ||||
|
|
||||
| // ContentStore returns content store | ||||
| func (w *Worker) ContentStore() content.Store { | ||||
| return w.Opt.ContentStore | ||||
| } | ||||
|
|
||||
| // LeaseManager returns leases.Manager for the worker | ||||
| func (w *Worker) LeaseManager() leases.Manager { | ||||
| return w.Opt.LeaseManager | ||||
| } | ||||
|
|
||||
| // LoadRef loads a reference by ID | ||||
| func (w *Worker) LoadRef(ctx context.Context, id string, hidden bool) (cache.ImmutableRef, error) { | ||||
| var opts []cache.RefOption | ||||
| if hidden { | ||||
| opts = append(opts, cache.NoUpdateLastUsed) | ||||
| } | ||||
| if id == "" { | ||||
| // results can have nil refs if they are optimized out to be equal to scratch, | ||||
| // i.e. Diff(A,A) == scratch | ||||
| return nil, nil | ||||
| } | ||||
|
|
||||
| return w.CacheManager().Get(ctx, id, nil, opts...) | ||||
| } | ||||
|
|
||||
|
|
||||
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.
Note to self; we can remove this once moby/buildkit#3567 is merged and cherry-picked in the 0.11 branch