65
65
Proxy : nhttp .ProxyFromEnvironment ,
66
66
DialContext : (& net.Dialer {
67
67
Timeout : 30 * time .Second ,
68
- KeepAlive : 30 * time .Second ,
68
+ KeepAlive : 90 * time .Second ,
69
69
DualStack : true ,
70
70
}).DialContext ,
71
71
MaxIdleConns : 100 ,
77
77
Proxy : nhttp .ProxyFromEnvironment ,
78
78
DialContext : (& net.Dialer {
79
79
Timeout : 30 * time .Second ,
80
- KeepAlive : 30 * time .Second ,
80
+ KeepAlive : 90 * time .Second ,
81
81
DualStack : true ,
82
82
}).DialContext ,
83
83
MaxIdleConns : 100 ,
@@ -86,24 +86,49 @@ var (
86
86
ExpectContinueTimeout : 1 * time .Second ,
87
87
TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
88
88
}
89
+ sharedHTTPTransportShortTimeout = & nhttp.Transport {
90
+ Proxy : nhttp .ProxyFromEnvironment ,
91
+ DialContext : (& net.Dialer {
92
+ Timeout : 30 * time .Second ,
93
+ KeepAlive : 100 * time .Millisecond ,
94
+ DualStack : true ,
95
+ }).DialContext ,
96
+ MaxIdleConns : 100 ,
97
+ IdleConnTimeout : 100 * time .Millisecond ,
98
+ TLSHandshakeTimeout : 10 * time .Second ,
99
+ ExpectContinueTimeout : 1 * time .Second ,
100
+ }
101
+ sharedHTTPSTransportShortTimeout = & nhttp.Transport {
102
+ Proxy : nhttp .ProxyFromEnvironment ,
103
+ DialContext : (& net.Dialer {
104
+ Timeout : 30 * time .Second ,
105
+ KeepAlive : 100 * time .Millisecond ,
106
+ DualStack : true ,
107
+ }).DialContext ,
108
+ MaxIdleConns : 100 ,
109
+ IdleConnTimeout : 100 * time .Millisecond ,
110
+ TLSHandshakeTimeout : 10 * time .Second ,
111
+ ExpectContinueTimeout : 1 * time .Second ,
112
+ TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
113
+ }
89
114
)
90
115
91
116
// CreateArangodClient creates a go-driver client for a specific member in the given group.
92
117
func CreateArangodClient (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , group api.ServerGroup , id string ) (driver.Client , error ) {
93
118
// Create connection
94
119
dnsName := k8sutil .CreatePodDNSName (apiObject , group .AsRole (), id )
95
- c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName )
120
+ c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName , false )
96
121
if err != nil {
97
122
return nil , maskAny (err )
98
123
}
99
124
return c , nil
100
125
}
101
126
102
127
// CreateArangodDatabaseClient creates a go-driver client for accessing the entire cluster (or single server).
103
- func CreateArangodDatabaseClient (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment ) (driver.Client , error ) {
128
+ func CreateArangodDatabaseClient (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , shortTimeout bool ) (driver.Client , error ) {
104
129
// Create connection
105
130
dnsName := k8sutil .CreateDatabaseClientServiceDNSName (apiObject )
106
- c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName )
131
+ c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName , shortTimeout )
107
132
if err != nil {
108
133
return nil , maskAny (err )
109
134
}
@@ -117,7 +142,8 @@ func CreateArangodAgencyClient(ctx context.Context, cli corev1.CoreV1Interface,
117
142
dnsName := k8sutil .CreatePodDNSName (apiObject , api .ServerGroupAgents .AsRole (), m .ID )
118
143
dnsNames = append (dnsNames , dnsName )
119
144
}
120
- connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , dnsNames )
145
+ shortTimeout := false
146
+ connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , dnsNames , shortTimeout )
121
147
if err != nil {
122
148
return nil , maskAny (err )
123
149
}
@@ -147,16 +173,16 @@ func CreateArangodAgencyClient(ctx context.Context, cli corev1.CoreV1Interface,
147
173
func CreateArangodImageIDClient (ctx context.Context , deployment k8sutil.APIObject , role , id string ) (driver.Client , error ) {
148
174
// Create connection
149
175
dnsName := k8sutil .CreatePodDNSName (deployment , role , id )
150
- c , err := createArangodClientForDNSName (ctx , nil , nil , dnsName )
176
+ c , err := createArangodClientForDNSName (ctx , nil , nil , dnsName , false )
151
177
if err != nil {
152
178
return nil , maskAny (err )
153
179
}
154
180
return c , nil
155
181
}
156
182
157
183
// CreateArangodClientForDNSName creates a go-driver client for a given DNS name.
158
- func createArangodClientForDNSName (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , dnsName string ) (driver.Client , error ) {
159
- connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , []string {dnsName })
184
+ func createArangodClientForDNSName (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , dnsName string , shortTimeout bool ) (driver.Client , error ) {
185
+ connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , []string {dnsName }, shortTimeout )
160
186
if err != nil {
161
187
return nil , maskAny (err )
162
188
}
@@ -183,12 +209,18 @@ func createArangodClientForDNSName(ctx context.Context, cli corev1.CoreV1Interfa
183
209
}
184
210
185
211
// createArangodHTTPConfigForDNSNames creates a go-driver HTTP connection config for a given DNS names.
186
- func createArangodHTTPConfigForDNSNames (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , dnsNames []string ) (http.ConnectionConfig , error ) {
212
+ func createArangodHTTPConfigForDNSNames (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , dnsNames []string , shortTimeout bool ) (http.ConnectionConfig , error ) {
187
213
scheme := "http"
188
214
transport := sharedHTTPTransport
215
+ if shortTimeout {
216
+ transport = sharedHTTPTransportShortTimeout
217
+ }
189
218
if apiObject != nil && apiObject .Spec .IsSecure () {
190
219
scheme = "https"
191
220
transport = sharedHTTPSTransport
221
+ if shortTimeout {
222
+ transport = sharedHTTPSTransportShortTimeout
223
+ }
192
224
}
193
225
connConfig := http.ConnectionConfig {
194
226
Transport : transport ,
0 commit comments