From 83f3691c1526dba6d2914ca1e1947568c9f6235b Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Mon, 31 Oct 2022 11:19:47 +0000 Subject: [PATCH] driver: don't create tracer delegate opt if tracer is nil The error handling for the cast to client.TracerDelegate was incorrect, and previously, a client would unconditionally append an opt. This results in the scenario that while the ClientOpt was not nil, the tracer delegate in the ClientOpt was, which isn't an error case explicitly handled by buildkit. Signed-off-by: Justin Chadwell --- driver/docker-container/driver.go | 11 +++++++---- driver/kubernetes/driver.go | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/driver/docker-container/driver.go b/driver/docker-container/driver.go index a7659f7e..19e4bec4 100644 --- a/driver/docker-container/driver.go +++ b/driver/docker-container/driver.go @@ -357,11 +357,14 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) { return nil, err } - td, _ := exp.(client.TracerDelegate) - - return client.New(ctx, "", client.WithContextDialer(func(context.Context, string) (net.Conn, error) { + var opts []client.ClientOpt + opts = append(opts, client.WithContextDialer(func(context.Context, string) (net.Conn, error) { return conn, nil - }), client.WithTracerDelegate(td)) + })) + if td, ok := exp.(client.TracerDelegate); ok { + opts = append(opts, client.WithTracerDelegate(td)) + } + return client.New(ctx, "", opts...) } func (d *Driver) Factory() driver.Factory { diff --git a/driver/kubernetes/driver.go b/driver/kubernetes/driver.go index 7fae8170..39e8c528 100644 --- a/driver/kubernetes/driver.go +++ b/driver/kubernetes/driver.go @@ -215,11 +215,14 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) { return nil, err } - td, _ := exp.(client.TracerDelegate) - - return client.New(ctx, "", client.WithContextDialer(func(context.Context, string) (net.Conn, error) { + var opts []client.ClientOpt + opts = append(opts, client.WithContextDialer(func(context.Context, string) (net.Conn, error) { return conn, nil - }), client.WithTracerDelegate(td)) + })) + if td, ok := exp.(client.TracerDelegate); ok { + opts = append(opts, client.WithTracerDelegate(td)) + } + return client.New(ctx, "", opts...) } func (d *Driver) Factory() driver.Factory {