Skip to content

Commit 3300f35

Browse files
committed
Fixed client wrt https
1 parent ea9c4b2 commit 3300f35

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pkg/util/arangod/client.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package arangod
2424

2525
import (
2626
"context"
27+
"crypto/tls"
2728
"fmt"
2829
"net"
2930
nhttp "net/http"
@@ -70,6 +71,19 @@ var (
7071
TLSHandshakeTimeout: 10 * time.Second,
7172
ExpectContinueTimeout: 1 * time.Second,
7273
}
74+
sharedHTTPSTransport = &nhttp.Transport{
75+
Proxy: nhttp.ProxyFromEnvironment,
76+
DialContext: (&net.Dialer{
77+
Timeout: 30 * time.Second,
78+
KeepAlive: 30 * time.Second,
79+
DualStack: true,
80+
}).DialContext,
81+
MaxIdleConns: 100,
82+
IdleConnTimeout: 90 * time.Second,
83+
TLSHandshakeTimeout: 10 * time.Second,
84+
ExpectContinueTimeout: 1 * time.Second,
85+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
86+
}
7387
)
7488

7589
// CreateArangodClient creates a go-driver client for a specific member in the given group.
@@ -97,11 +111,16 @@ func CreateArangodDatabaseClient(ctx context.Context, cli corev1.CoreV1Interface
97111
// CreateArangodClientForDNSName creates a go-driver client for a given DNS name.
98112
func createArangodClientForDNSName(ctx context.Context, cli corev1.CoreV1Interface, apiObject *api.ArangoDeployment, dnsName string) (driver.Client, error) {
99113
scheme := "http"
114+
transport := sharedHTTPTransport
115+
if apiObject.Spec.IsSecure() {
116+
scheme = "https"
117+
transport = sharedHTTPSTransport
118+
}
100119
connConfig := http.ConnectionConfig{
101120
Endpoints: []string{scheme + "://" + net.JoinHostPort(dnsName, strconv.Itoa(k8sutil.ArangoPort))},
102-
Transport: sharedHTTPTransport,
121+
Transport: transport,
103122
}
104-
// TODO deal with TLS
123+
// TODO deal with TLS with proper CA checking
105124
conn, err := http.NewConnection(connConfig)
106125
if err != nil {
107126
return nil, maskAny(err)

0 commit comments

Comments
 (0)