Skip to content

Commit

Permalink
Merge pull request docker#1934 from jedevc/use-buildkit-client-wait
Browse files Browse the repository at this point in the history
  • Loading branch information
jedevc authored Jul 19, 2023
2 parents 23fe029 + e11c5e3 commit b8739d7
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions driver/remote/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/docker/buildx/driver"
"github.com/docker/buildx/util/progress"
"github.com/moby/buildkit/client"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
)

type Driver struct {
Expand All @@ -23,25 +25,11 @@ type tlsOpts struct {
}

func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
for i := 0; ; i++ {
info, err := d.Info(ctx)
if err != nil {
return err
}
if info.Status != driver.Inactive {
return nil
}

select {
case <-ctx.Done():
return ctx.Err()
default:
if i > 10 {
i = 10
}
time.Sleep(time.Duration(i) * time.Second)
}
c, err := d.Client(ctx)
if err != nil {
return err
}
return c.Wait(ctx)
}

func (d *Driver) Info(ctx context.Context) (*driver.Info, error) {
Expand Down Expand Up @@ -77,6 +65,13 @@ func (d *Driver) Rm(ctx context.Context, force, rmVolume, rmDaemon bool) error {

func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
opts := []client.ClientOpt{}

backoffConfig := backoff.DefaultConfig
backoffConfig.MaxDelay = 1 * time.Second
opts = append(opts, client.WithGRPCDialOption(
grpc.WithConnectParams(grpc.ConnectParams{Backoff: backoffConfig}),
))

if d.tlsOpts != nil {
opts = append(opts, []client.ClientOpt{
client.WithServerConfig(d.tlsOpts.serverName, d.tlsOpts.caCert),
Expand Down

0 comments on commit b8739d7

Please sign in to comment.