From 7dc66eee641c8c622113852275cdabe9deb1aca5 Mon Sep 17 00:00:00 2001 From: zounengren Date: Wed, 20 Jul 2022 22:53:42 +0800 Subject: [PATCH] using ContextDialer instead Signed-off-by: zounengren --- pkg/ttrpcutil/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/ttrpcutil/client.go b/pkg/ttrpcutil/client.go index f05ab7aa9..e1c1b6cf9 100644 --- a/pkg/ttrpcutil/client.go +++ b/pkg/ttrpcutil/client.go @@ -17,6 +17,7 @@ package ttrpcutil import ( + "context" "errors" "fmt" "sync" @@ -42,7 +43,9 @@ type Client struct { // NewClient returns a new containerd TTRPC client that is connected to the containerd instance provided by address func NewClient(address string, opts ...ttrpc.ClientOpts) (*Client, error) { connector := func() (*ttrpc.Client, error) { - conn, err := dialer.Dialer(address, ttrpcDialTimeout) + ctx, cancel := context.WithTimeout(context.Background(), ttrpcDialTimeout) + defer cancel() + conn, err := dialer.ContextDialer(ctx, address) if err != nil { return nil, fmt.Errorf("failed to connect: %w", err) }