From c1a4fb4922a9eb907b0e552109f74b0d88fe39dc Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Wed, 24 Apr 2019 18:26:58 +0000 Subject: [PATCH] update vndr moby/buildkit 8818c67 Signed-off-by: Andrew Hsu --- vendor.conf | 2 +- vendor/github.com/moby/buildkit/README.md | 24 +++- .../github.com/moby/buildkit/client/solve.go | 128 ++++++++++-------- .../util/progress/progressui/display.go | 5 +- 4 files changed, 94 insertions(+), 65 deletions(-) diff --git a/vendor.conf b/vendor.conf index 021c805571..5439bd405f 100755 --- a/vendor.conf +++ b/vendor.conf @@ -51,7 +51,7 @@ github.com/Microsoft/go-winio 84b4ab48a50763fe7b3abcef38e5 github.com/Microsoft/hcsshim 672e52e9209d1e53718c1b6a7d68cc9272654ab5 github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac -github.com/moby/buildkit b3028967ae6259c9a31c1a1deeccd30fe3469cce +github.com/moby/buildkit 8818c67cff663befa7b70f21454e340f71616581 github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3 github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1 github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b diff --git a/vendor/github.com/moby/buildkit/README.md b/vendor/github.com/moby/buildkit/README.md index 47da288acc..39605c0e02 100644 --- a/vendor/github.com/moby/buildkit/README.md +++ b/vendor/github.com/moby/buildkit/README.md @@ -38,7 +38,7 @@ BuildKit is used by the following projects: - [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud) - [container build interface](https://github.com/containerbuilding/cbi) - [Knative Build Templates](https://github.com/knative/build-templates) -- [boss](https://github.com/crosbymichael/boss) +- [vab](https://github.com/stellarproject/vab) - [Rio](https://github.com/rancher/rio) (on roadmap) ### Quick start @@ -100,7 +100,7 @@ To start building use `buildctl build` command. The example script accepts `--wi go run examples/buildkit0/buildkit.go | buildctl build ``` -`buildctl build` will show interactive progress bar by default while the build job is running. It will also show you the path to the trace file that contains all information about the timing of the individual steps and logs. +`buildctl build` will show interactive progress bar by default while the build job is running. If the path to the trace file is specified, the trace file generated will contain all information about the timing of the individual steps and logs. Different versions of the example scripts show different ways of describing the build definition for this project to show the capabilities of the library. New versions have been added when new features have become available. @@ -218,8 +218,8 @@ buildctl build ... --import-cache type=registry,ref=localhost:5000/myrepo:buildc #### To/From local filesystem ``` -buildctl build ... --export-cache type=local,src=path/to/input-dir -buildctl build ... --import-cache type=local,dest=path/to/output-dir +buildctl build ... --export-cache type=local,dest=path/to/output-dir +buildctl build ... --import-cache type=local,src=path/to/input-dir ``` The directory layout conforms to OCI Image Spec v1.0. @@ -228,11 +228,11 @@ The directory layout conforms to OCI Image Spec v1.0. * `mode=min` (default): only export layers for the resulting image * `mode=max`: export all the layers of all intermediate steps * `ref=docker.io/user/image:tag`: reference for `registry` cache exporter -* `src=path/to/output-dir`: directory for `local` cache exporter +* `dest=path/to/output-dir`: directory for `local` cache exporter #### `--import-cache` options * `ref=docker.io/user/image:tag`: reference for `registry` cache importer -* `dest=path/to/input-dir`: directory for `local` cache importer +* `src=path/to/input-dir`: directory for `local` cache importer * `digest=sha256:deadbeef`: digest of the manifest list to import for `local` cache importer. Defaults to the digest of "latest" tag in `index.json` ### Other @@ -271,6 +271,18 @@ buildctl build --help The images can be also built locally using `./hack/dockerfiles/test.Dockerfile` (or `./hack/dockerfiles/test.buildkit.Dockerfile` if you already have BuildKit). Run `make images` to build the images as `moby/buildkit:local` and `moby/buildkit:local-rootless`. +#### Connection helpers + +If you are running `moby/buildkit:master` or `moby/buildkit:master-rootless` as a Docker/Kubernetes container, you can use special `BUILDKIT_HOST` URL for connecting to the BuildKit daemon in the container: + +``` +export BUILDKIT_HOST=docker:// +``` + +``` +export BUILDKIT_HOST=kube-pod:// +``` + ### Opentracing support BuildKit supports opentracing for buildkitd gRPC API and buildctl commands. To capture the trace to [Jaeger](https://github.com/jaegertracing/jaeger), set `JAEGER_TRACE` environment variable to the collection address. diff --git a/vendor/github.com/moby/buildkit/client/solve.go b/vendor/github.com/moby/buildkit/client/solve.go index d772eaa398..830c018cbb 100644 --- a/vendor/github.com/moby/buildkit/client/solve.go +++ b/vendor/github.com/moby/buildkit/client/solve.go @@ -30,15 +30,17 @@ import ( ) type SolveOpt struct { - Exports []ExportEntry - LocalDirs map[string]string - SharedKey string - Frontend string - FrontendAttrs map[string]string - CacheExports []CacheOptionsEntry - CacheImports []CacheOptionsEntry - Session []session.Attachable - AllowedEntitlements []entitlements.Entitlement + Exports []ExportEntry + LocalDirs map[string]string + SharedKey string + Frontend string + FrontendAttrs map[string]string + CacheExports []CacheOptionsEntry + CacheImports []CacheOptionsEntry + Session []session.Attachable + AllowedEntitlements []entitlements.Entitlement + SharedSession *session.Session // TODO: refactor to better session syncing + SessionPreInitialized bool // TODO: refactor to better session syncing } type ExportEntry struct { @@ -94,50 +96,15 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG statusContext = opentracing.ContextWithSpan(statusContext, span) } - s, err := session.NewSession(statusContext, defaultSessionName(), opt.SharedKey) - if err != nil { - return nil, errors.Wrap(err, "failed to create session") - } + s := opt.SharedSession - if len(syncedDirs) > 0 { - s.Allow(filesync.NewFSSyncProvider(syncedDirs)) - } - - for _, a := range opt.Session { - s.Allow(a) - } - - var ex ExportEntry - if len(opt.Exports) > 1 { - return nil, errors.New("currently only single Exports can be specified") - } - if len(opt.Exports) == 1 { - ex = opt.Exports[0] - } - - switch ex.Type { - case ExporterLocal: - if ex.Output != nil { - return nil, errors.New("output file writer is not supported by local exporter") + if s == nil { + if opt.SessionPreInitialized { + return nil, errors.Errorf("no session provided for preinitialized option") } - if ex.OutputDir == "" { - return nil, errors.New("output directory is required for local exporter") - } - s.Allow(filesync.NewFSSyncTargetDir(ex.OutputDir)) - case ExporterOCI, ExporterDocker, ExporterTar: - if ex.OutputDir != "" { - return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type) - } - if ex.Output == nil { - return nil, errors.Errorf("output file writer is required for %s exporter", ex.Type) - } - s.Allow(filesync.NewFSSyncTarget(ex.Output)) - default: - if ex.Output != nil { - return nil, errors.Errorf("output file writer is not supported by %s exporter", ex.Type) - } - if ex.OutputDir != "" { - return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type) + s, err = session.NewSession(statusContext, defaultSessionName(), opt.SharedKey) + if err != nil { + return nil, errors.Wrap(err, "failed to create session") } } @@ -145,17 +112,64 @@ func (c *Client) solve(ctx context.Context, def *llb.Definition, runGateway runG if err != nil { return nil, err } - if len(cacheOpt.contentStores) > 0 { - s.Allow(sessioncontent.NewAttachable(cacheOpt.contentStores)) + + var ex ExportEntry + + if !opt.SessionPreInitialized { + if len(syncedDirs) > 0 { + s.Allow(filesync.NewFSSyncProvider(syncedDirs)) + } + + for _, a := range opt.Session { + s.Allow(a) + } + + if len(opt.Exports) > 1 { + return nil, errors.New("currently only single Exports can be specified") + } + if len(opt.Exports) == 1 { + ex = opt.Exports[0] + } + + switch ex.Type { + case ExporterLocal: + if ex.Output != nil { + return nil, errors.New("output file writer is not supported by local exporter") + } + if ex.OutputDir == "" { + return nil, errors.New("output directory is required for local exporter") + } + s.Allow(filesync.NewFSSyncTargetDir(ex.OutputDir)) + case ExporterOCI, ExporterDocker, ExporterTar: + if ex.OutputDir != "" { + return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type) + } + if ex.Output == nil { + return nil, errors.Errorf("output file writer is required for %s exporter", ex.Type) + } + s.Allow(filesync.NewFSSyncTarget(ex.Output)) + default: + if ex.Output != nil { + return nil, errors.Errorf("output file writer is not supported by %s exporter", ex.Type) + } + if ex.OutputDir != "" { + return nil, errors.Errorf("output directory %s is not supported by %s exporter", ex.OutputDir, ex.Type) + } + } + + if len(cacheOpt.contentStores) > 0 { + s.Allow(sessioncontent.NewAttachable(cacheOpt.contentStores)) + } + + eg.Go(func() error { + return s.Run(statusContext, grpchijack.Dialer(c.controlClient())) + }) } + for k, v := range cacheOpt.frontendAttrs { opt.FrontendAttrs[k] = v } - eg.Go(func() error { - return s.Run(statusContext, grpchijack.Dialer(c.controlClient())) - }) - solveCtx, cancelSolve := context.WithCancel(ctx) var res *SolveResponse eg.Go(func() error { diff --git a/vendor/github.com/moby/buildkit/util/progress/progressui/display.go b/vendor/github.com/moby/buildkit/util/progress/progressui/display.go index 96340197ec..e7fee54df5 100644 --- a/vendor/github.com/moby/buildkit/util/progress/progressui/display.go +++ b/vendor/github.com/moby/buildkit/util/progress/progressui/display.go @@ -227,7 +227,10 @@ func (t *trace) update(s *client.SolveStatus, termWidth int) { } t.vertexes = append(t.vertexes, t.byDigest[v.Digest]) } - t.byDigest[v.Digest].Vertex = v + // allow a duplicate initial vertex that shouldn't reset state + if !(prev != nil && prev.Started != nil && v.Started == nil) { + t.byDigest[v.Digest].Vertex = v + } t.byDigest[v.Digest].jobCached = false } for _, s := range s.Statuses {