Skip to content

Commit 82bd4c3

Browse files
committed
fix webhook health check tls handshake timeouts
Signed-off-by: Stefan Büringer [email protected]
1 parent 8348079 commit 82bd4c3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/webhook/server.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ func (s *Server) Start(ctx context.Context) error {
292292
// StartedChecker returns an healthz.Checker which is healthy after the
293293
// server has been started.
294294
func (s *Server) StartedChecker() healthz.Checker {
295+
config := &tls.Config{
296+
InsecureSkipVerify: true, // nolint:gosec // config is used to connect to our own webhook port.
297+
}
295298
return func(req *http.Request) error {
296299
s.mu.Lock()
297300
defer s.mu.Unlock()
@@ -300,11 +303,15 @@ func (s *Server) StartedChecker() healthz.Checker {
300303
return fmt.Errorf("webhook server has not been started yet")
301304
}
302305

303-
conn, err := net.DialTimeout("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)), 10*time.Second)
306+
d := &net.Dialer{Timeout: 10 * time.Second}
307+
conn, err := tls.DialWithDialer(d, "tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port)), config)
304308
if err != nil {
305309
return fmt.Errorf("webhook server is not reachable: %v", err)
306310
}
307-
conn.Close()
311+
312+
if err := conn.Close(); err != nil {
313+
return fmt.Errorf("webhook server is not reachable: closing connection: %v", err)
314+
}
308315

309316
return nil
310317
}

0 commit comments

Comments
 (0)