@@ -17,6 +17,7 @@ package provisioner
17
17
18
18
import (
19
19
"context"
20
+ "google.golang.org/grpc/backoff"
20
21
"net/url"
21
22
"time"
22
23
@@ -28,16 +29,21 @@ import (
28
29
)
29
30
30
31
const (
31
- maxGrpcBackoff = 30 * time .Second
32
+ maxGrpcBackoff = 5 * 30 * time .Second
32
33
grpcDialTimeout = 30 * time .Second
33
34
)
34
35
35
36
func NewDefaultCOSIProvisionerClient (ctx context.Context , address string , debug bool ) (* COSIProvisionerClient , error ) {
37
+ backoffConfiguration := backoff .DefaultConfig
38
+ backoffConfiguration .MaxDelay = maxGrpcBackoff
39
+
36
40
dialOpts := []grpc.DialOption {
37
41
grpc .WithInsecure (), // strictly restricting to local Unix domain socket
38
- grpc .WithBackoffMaxDelay (maxGrpcBackoff ),
42
+ grpc .WithConnectParams (grpc.ConnectParams {
43
+ Backoff : backoffConfiguration ,
44
+ MinConnectTimeout : grpcDialTimeout ,
45
+ }),
39
46
grpc .WithBlock (), // block until connection succeeds
40
- grpc .WithTimeout (grpcDialTimeout ),
41
47
}
42
48
43
49
interceptors := []grpc.UnaryClientInterceptor {}
@@ -65,12 +71,14 @@ func NewCOSIProvisionerClient(ctx context.Context, address string, dialOpts []gr
65
71
dialOpts = append (dialOpts , grpc .WithChainUnaryInterceptor (interceptor ))
66
72
}
67
73
74
+ ctx , cancel := context .WithTimeout (ctx , maxGrpcBackoff )
75
+ defer cancel ()
76
+
68
77
conn , err := grpc .DialContext (ctx , address , dialOpts ... )
69
78
if err != nil {
70
79
klog .ErrorS (err , "Connection failed" , "address" , address )
71
80
return nil , err
72
81
}
73
-
74
82
return & COSIProvisionerClient {
75
83
address : address ,
76
84
conn : conn ,
0 commit comments