@@ -19,6 +19,7 @@ package sidecar
19
19
import (
20
20
"crypto/tls"
21
21
"fmt"
22
+ "io"
22
23
"net/http"
23
24
"time"
24
25
@@ -78,6 +79,14 @@ func configureProbesServer(c *Controller, tenantTLS bool) *http.Server {
78
79
return s
79
80
}
80
81
82
+ // we do insecure skip verify because we are checking against the local instance and don't care for the certificate
83
+ var probeHTTPClient = & http.Client {
84
+ Timeout : time .Millisecond * 500 ,
85
+ Transport : & http.Transport {
86
+ TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
87
+ },
88
+ }
89
+
81
90
func readinessHandler (tenantTLS bool ) func (w http.ResponseWriter , r * http.Request ) {
82
91
return func (w http.ResponseWriter , r * http.Request ) {
83
92
schema := "https"
@@ -92,21 +101,13 @@ func readinessHandler(tenantTLS bool) func(w http.ResponseWriter, r *http.Reques
92
101
return
93
102
}
94
103
95
- // we do insecure skip verify because we are checking against the local instance and don't care for the
96
- // certificate
97
- client := & http.Client {
98
- Timeout : time .Millisecond * 500 ,
99
- Transport : & http.Transport {
100
- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
101
- },
102
- }
103
-
104
- response , err := client .Do (request )
104
+ response , err := probeHTTPClient .Do (request )
105
105
if err != nil {
106
106
http .Error (w , fmt .Sprintf ("HTTP request failed: %s" , err ), http .StatusInternalServerError )
107
107
return
108
108
}
109
109
defer response .Body .Close ()
110
+ _ , _ = io .Copy (io .Discard , response .Body ) // Discard body to enable connection reuse
110
111
111
112
if response .StatusCode == 403 {
112
113
fmt .Fprintln (w , "Readiness probe succeeded." )
0 commit comments