From b6696428ef5f0498d4f1c5c2c99e74bb47a244c5 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Sun, 14 Jul 2024 00:04:08 +0000 Subject: [PATCH] Add dial duration to debug error message This should give us more detail on how long dials take before failing, so that we can perhaps better tune the retry loop in the future. Signed-off-by: Brad Davidson --- pkg/agent/loadbalancer/loadbalancer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/agent/loadbalancer/loadbalancer.go b/pkg/agent/loadbalancer/loadbalancer.go index 36019470c8d2..567d825a2bb7 100644 --- a/pkg/agent/loadbalancer/loadbalancer.go +++ b/pkg/agent/loadbalancer/loadbalancer.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "sync" + "time" "github.com/k3s-io/k3s/pkg/version" "github.com/sirupsen/logrus" @@ -167,11 +168,12 @@ func (lb *LoadBalancer) dialContext(ctx context.Context, network, _ string) (net if server == nil || targetServer == "" { logrus.Debugf("Nil server for load balancer %s: %s", lb.serviceName, targetServer) } else if allChecksFailed || server.healthCheck() { + dialTime := time.Now() conn, err := server.dialContext(ctx, network, targetServer) if err == nil { return conn, nil } - logrus.Debugf("Dial error from load balancer %s: %s", lb.serviceName, err) + logrus.Debugf("Dial error from load balancer %s after %s: %s", lb.serviceName, time.Now().Sub(dialTime), err) // Don't close connections to the failed server if we're retrying with health checks ignored. // We don't want to disrupt active connections if it is unlikely they will have anywhere to go. if !allChecksFailed {