From 63052e3dacb64de3b16aadce12e8dad0f8080623 Mon Sep 17 00:00:00 2001 From: Carlos Salas Date: Thu, 31 Oct 2024 10:55:29 +0100 Subject: [PATCH] fix: remove deprecated grpc.WithBlock Signed-off-by: Carlos Salas --- pkg/etcd/etcd.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/etcd/etcd.go b/pkg/etcd/etcd.go index aa7c3dc1..56d1ae6c 100644 --- a/pkg/etcd/etcd.go +++ b/pkg/etcd/etcd.go @@ -145,15 +145,18 @@ func NewClient(ctx context.Context, config ClientConfiguration) (*Client, error) return nil, errors.Wrap(err, "unable to create a dialer for etcd client") } + // Use a specific context with a timeout for the etcd client + clientCtx, cancel := context.WithTimeout(context.Background(), config.DialTimeout) + defer cancel() + c := clientv3.Config{ // NOTE: endpoint is used only as a host for certificate validation, the network connection is defined by DialOptions. - Endpoints: []string{config.Endpoint}, - DialTimeout: config.DialTimeout, + Endpoints: []string{config.Endpoint}, DialOptions: []grpc.DialOption{ - grpc.WithBlock(), // block until the underlying connection is up grpc.WithContextDialer(dialer.DialContextWithAddr), }, - TLS: config.TLSConfig, + TLS: config.TLSConfig, + Context: clientCtx, } etcdClient, err := clientv3.New(c)