From 6064386787cc55d571cc777b4f04c2d2e4d8a6ca Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 14 Oct 2024 08:22:47 +0200 Subject: [PATCH] add timeout to tcp checker Signed-off-by: Christian Richter --- ocis-pkg/handlers/checktcp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ocis-pkg/handlers/checktcp.go b/ocis-pkg/handlers/checktcp.go index a09e6570cd..0db97bfabf 100644 --- a/ocis-pkg/handlers/checktcp.go +++ b/ocis-pkg/handlers/checktcp.go @@ -3,12 +3,13 @@ package handlers import ( "context" "net" + "time" ) // NewTCPCheck returns a check that connects to a given tcp endpoint. func NewTCPCheck(address string) func(ctx context.Context) error { return func(_ context.Context) error { - conn, err := net.Dial("tcp", address) + conn, err := net.DialTimeout("tcp", address, 3*time.Second) if err != nil { return err }