Skip to content

Commit 97e0efa

Browse files
authored
Merge pull request moby#4200 from jedevc/fix-client-wait
2 parents 3d44ec2 + f1d7f2e commit 97e0efa

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

client/client.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/url"
99
"os"
1010
"strings"
11+
"time"
1112

1213
contentapi "github.com/containerd/containerd/api/services/content/v1"
1314
"github.com/containerd/containerd/defaults"
@@ -186,16 +187,29 @@ func (c *Client) Dialer() session.Dialer {
186187
}
187188

188189
func (c *Client) Wait(ctx context.Context) error {
189-
opts := []grpc.CallOption{grpc.WaitForReady(true)}
190-
_, err := c.ControlClient().Info(ctx, &controlapi.InfoRequest{}, opts...)
191-
if err != nil {
192-
if code := grpcerrors.Code(err); code == codes.Unimplemented {
190+
for {
191+
_, err := c.ControlClient().Info(ctx, &controlapi.InfoRequest{})
192+
if err == nil {
193+
return nil
194+
}
195+
196+
switch code := grpcerrors.Code(err); code {
197+
case codes.Unavailable:
198+
case codes.Unimplemented:
193199
// only buildkit v0.11+ supports the info api, but an unimplemented
194200
// response error is still a response so we can ignore it
195201
return nil
202+
default:
203+
return err
204+
}
205+
206+
select {
207+
case <-ctx.Done():
208+
return ctx.Err()
209+
case <-time.After(time.Second):
196210
}
211+
c.conn.ResetConnectBackoff()
197212
}
198-
return err
199213
}
200214

201215
func (c *Client) Close() error {

cmd/buildctl/common/common.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import (
1616
"github.com/pkg/errors"
1717
"github.com/urfave/cli"
1818
"go.opentelemetry.io/otel/trace"
19-
"google.golang.org/grpc"
20-
"google.golang.org/grpc/backoff"
2119
)
2220

2321
// ResolveClient resolves a client from CLI args
@@ -69,12 +67,6 @@ func ResolveClient(c *cli.Context) (*client.Client, error) {
6967

7068
opts := []client.ClientOpt{client.WithFailFast()}
7169

72-
backoffConfig := backoff.DefaultConfig
73-
backoffConfig.MaxDelay = 1 * time.Second
74-
opts = append(opts, client.WithGRPCDialOption(
75-
grpc.WithConnectParams(grpc.ConnectParams{Backoff: backoffConfig}),
76-
))
77-
7870
ctx := CommandContext(c)
7971

8072
if span := trace.SpanFromContext(ctx); span.SpanContext().IsValid() {

0 commit comments

Comments
 (0)