use dailcontext

Kubernetes-commit: 89f3fa3d62791e756dcbd645818ea03d7c1a86b8
This commit is contained in:
fisherxu 2018-08-24 10:18:21 +08:00 committed by Kubernetes Publisher
parent 67c8928411
commit 164f30a663
1 changed files with 4 additions and 1 deletions

View File

@ -59,7 +59,10 @@ func NewGRPCService(endpoint string) (Service, error) {
return nil, err
}
connection, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithTimeout(timeout), grpc.WithDialer(unixDial))
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
connection, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithDialer(unixDial))
if err != nil {
return nil, fmt.Errorf("connect remote KMS provider %q failed, error: %v", addr, err)
}