Skip to content

Commit 9d1bab8

Browse files
author
Miguel Varela Ramos
authored
Remove hardcoded timeout from proxy readiness probe (#2373)
1 parent 65f370f commit 9d1bab8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/proxy/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"context"
2121
"flag"
22+
"fmt"
2223
"net"
2324
"net/http"
2425
"os"
@@ -208,10 +209,11 @@ func exit(log *zap.SugaredLogger, err error, wrapStrs ...string) {
208209

209210
func readinessTCPHandler(port int, logger *zap.SugaredLogger) http.HandlerFunc {
210211
return func(w http.ResponseWriter, r *http.Request) {
211-
timeout := time.Duration(1) * time.Second
212-
address := net.JoinHostPort("localhost", strconv.FormatInt(int64(port), 10))
212+
ctx := r.Context()
213+
address := net.JoinHostPort("localhost", fmt.Sprintf("%d", port))
213214

214-
conn, err := net.DialTimeout("tcp", address, timeout)
215+
var d net.Dialer
216+
conn, err := d.DialContext(ctx, "tcp", address)
215217
if err != nil {
216218
logger.Warn(errors.Wrap(err, "TCP probe to user-provided container port failed"))
217219
w.WriteHeader(http.StatusInternalServerError)

0 commit comments

Comments
 (0)