Skip to content

Commit 4fc4bc0

Browse files
committed
vendor: update buildx to latest docker/cli
This version of docker/cli has changes to remove compose-cli wrapper and move all CLI metrics to OTEL. Signed-off-by: Jonathan A. Sternberg <[email protected]>
1 parent afcb609 commit 4fc4bc0

File tree

15 files changed

+204
-107
lines changed

15 files changed

+204
-107
lines changed

cmd/buildx/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"os"
67

@@ -15,6 +16,7 @@ import (
1516
cliflags "github.com/docker/cli/cli/flags"
1617
"github.com/moby/buildkit/solver/errdefs"
1718
"github.com/moby/buildkit/util/stack"
19+
"go.opentelemetry.io/otel"
1820

1921
//nolint:staticcheck // vendored dependencies may still use this
2022
"github.com/containerd/containerd/pkg/seed"
@@ -38,10 +40,27 @@ func runStandalone(cmd *command.DockerCli) error {
3840
if err := cmd.Initialize(cliflags.NewClientOptions()); err != nil {
3941
return err
4042
}
43+
defer flushMetrics(cmd)
44+
4145
rootCmd := commands.NewRootCmd(os.Args[0], false, cmd)
4246
return rootCmd.Execute()
4347
}
4448

49+
// flushMetrics will manually flush metrics from the configured
50+
// meter provider. This is needed when running in standalone mode
51+
// because the meter provider is initialized by the cli library,
52+
// but the mechanism for forcing it to report is not presently
53+
// exposed and not invoked when run in standalone mode.
54+
// There are plans to fix that in the next release, but this is
55+
// needed temporarily until the API for this is more thorough.
56+
func flushMetrics(cmd *command.DockerCli) {
57+
if mp, ok := cmd.MeterProvider().(command.MeterProvider); ok {
58+
if err := mp.ForceFlush(context.Background()); err != nil {
59+
otel.Handle(err)
60+
}
61+
}
62+
}
63+
4564
func runPlugin(cmd *command.DockerCli) error {
4665
rootCmd := commands.NewRootCmd("buildx", true, cmd)
4766
return plugin.RunPlugin(cmd, rootCmd, manager.Metadata{

commands/build.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ func (o *buildOptionsHash) String() string {
269269
}
270270

271271
func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions) (err error) {
272-
mp := dockerCli.MeterProvider(ctx)
273-
defer metricutil.Shutdown(ctx, mp)
272+
mp := dockerCli.MeterProvider()
274273

275274
ctx, end, err := tracing.TraceCurrentCommand(ctx, "build")
276275
if err != nil {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/containerd/typeurl/v2 v2.1.1
1515
github.com/creack/pty v1.1.18
1616
github.com/distribution/reference v0.5.0
17-
github.com/docker/cli v26.0.1-0.20240410153731-b6c552212837+incompatible // v26.1.0-dev
17+
github.com/docker/cli v26.1.3+incompatible
1818
github.com/docker/cli-docs-tool v0.7.0
1919
github.com/docker/docker v26.0.0+incompatible
2020
github.com/docker/go-units v0.5.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
117117
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
118118
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
119119
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
120-
github.com/docker/cli v26.0.1-0.20240410153731-b6c552212837+incompatible h1:KTmSJjZSQM+cpaczHecGsBNlgJtRccef/62pCOeiA9o=
121-
github.com/docker/cli v26.0.1-0.20240410153731-b6c552212837+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
120+
github.com/docker/cli v26.1.3+incompatible h1:bUpXT/N0kDE3VUHI2r5VMsYQgi38kYuoC0oL9yt3lqc=
121+
github.com/docker/cli v26.1.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
122122
github.com/docker/cli-docs-tool v0.7.0 h1:M2Da98Unz2kz3A5d4yeSGbhyOge2mfYSNjAFt01Rw0M=
123123
github.com/docker/cli-docs-tool v0.7.0/go.mod h1:zMjqTFCU361PRh8apiXzeAZ1Q/xupbIwTusYpzCXS/o=
124124
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=

util/metricutil/metric.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package metricutil
22

33
import (
4-
"context"
5-
64
"github.com/docker/buildx/version"
7-
"github.com/docker/cli/cli/command"
8-
"go.opentelemetry.io/otel"
95
"go.opentelemetry.io/otel/metric"
106
)
117

@@ -15,10 +11,3 @@ func Meter(mp metric.MeterProvider) metric.Meter {
1511
return mp.Meter(version.Package,
1612
metric.WithInstrumentationVersion(version.Version))
1713
}
18-
19-
// Shutdown invokes Shutdown on the MeterProvider and then reports any error to the OTEL handler.
20-
func Shutdown(ctx context.Context, mp command.MeterProvider) {
21-
if err := mp.Shutdown(ctx); err != nil {
22-
otel.Handle(err)
23-
}
24-
}

vendor/github.com/docker/cli/cli-plugins/hooks/template.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli-plugins/manager/hooks.go

Lines changed: 69 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli-plugins/manager/manager.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli-plugins/manager/plugin.go

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/cli/cli-plugins/plugin/plugin.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)