6565 Proxy : nhttp .ProxyFromEnvironment ,
6666 DialContext : (& net.Dialer {
6767 Timeout : 30 * time .Second ,
68- KeepAlive : 30 * time .Second ,
68+ KeepAlive : 90 * time .Second ,
6969 DualStack : true ,
7070 }).DialContext ,
7171 MaxIdleConns : 100 ,
7777 Proxy : nhttp .ProxyFromEnvironment ,
7878 DialContext : (& net.Dialer {
7979 Timeout : 30 * time .Second ,
80- KeepAlive : 30 * time .Second ,
80+ KeepAlive : 90 * time .Second ,
8181 DualStack : true ,
8282 }).DialContext ,
8383 MaxIdleConns : 100 ,
@@ -86,24 +86,49 @@ var (
8686 ExpectContinueTimeout : 1 * time .Second ,
8787 TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
8888 }
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+ }
89114)
90115
91116// CreateArangodClient creates a go-driver client for a specific member in the given group.
92117func CreateArangodClient (ctx context.Context , cli corev1.CoreV1Interface , apiObject * api.ArangoDeployment , group api.ServerGroup , id string ) (driver.Client , error ) {
93118 // Create connection
94119 dnsName := k8sutil .CreatePodDNSName (apiObject , group .AsRole (), id )
95- c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName )
120+ c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName , false )
96121 if err != nil {
97122 return nil , maskAny (err )
98123 }
99124 return c , nil
100125}
101126
102127// 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 ) {
104129 // Create connection
105130 dnsName := k8sutil .CreateDatabaseClientServiceDNSName (apiObject )
106- c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName )
131+ c , err := createArangodClientForDNSName (ctx , cli , apiObject , dnsName , shortTimeout )
107132 if err != nil {
108133 return nil , maskAny (err )
109134 }
@@ -117,7 +142,8 @@ func CreateArangodAgencyClient(ctx context.Context, cli corev1.CoreV1Interface,
117142 dnsName := k8sutil .CreatePodDNSName (apiObject , api .ServerGroupAgents .AsRole (), m .ID )
118143 dnsNames = append (dnsNames , dnsName )
119144 }
120- connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , dnsNames )
145+ shortTimeout := false
146+ connConfig , err := createArangodHTTPConfigForDNSNames (ctx , cli , apiObject , dnsNames , shortTimeout )
121147 if err != nil {
122148 return nil , maskAny (err )
123149 }
@@ -147,16 +173,16 @@ func CreateArangodAgencyClient(ctx context.Context, cli corev1.CoreV1Interface,
147173func CreateArangodImageIDClient (ctx context.Context , deployment k8sutil.APIObject , role , id string ) (driver.Client , error ) {
148174 // Create connection
149175 dnsName := k8sutil .CreatePodDNSName (deployment , role , id )
150- c , err := createArangodClientForDNSName (ctx , nil , nil , dnsName )
176+ c , err := createArangodClientForDNSName (ctx , nil , nil , dnsName , false )
151177 if err != nil {
152178 return nil , maskAny (err )
153179 }
154180 return c , nil
155181}
156182
157183// 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 )
160186 if err != nil {
161187 return nil , maskAny (err )
162188 }
@@ -183,12 +209,18 @@ func createArangodClientForDNSName(ctx context.Context, cli corev1.CoreV1Interfa
183209}
184210
185211// 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 ) {
187213 scheme := "http"
188214 transport := sharedHTTPTransport
215+ if shortTimeout {
216+ transport = sharedHTTPTransportShortTimeout
217+ }
189218 if apiObject != nil && apiObject .Spec .IsSecure () {
190219 scheme = "https"
191220 transport = sharedHTTPSTransport
221+ if shortTimeout {
222+ transport = sharedHTTPSTransportShortTimeout
223+ }
192224 }
193225 connConfig := http.ConnectionConfig {
194226 Transport : transport ,
0 commit comments