From 4db806b0d3bf413f50ac0d92b2e4c64b5da97b8c Mon Sep 17 00:00:00 2001 From: Roman Zavodskikh Date: Tue, 23 Apr 2024 19:54:01 +0200 Subject: [PATCH] Added PHC-related logs (#3036) Signed-off-by: Roman Zavodskikh Co-authored-by: Roman Zavodskikh --- proxy/healthy_endpoints.go | 8 +++++--- proxy/proxy.go | 2 +- routing/endpointregistry.go | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/proxy/healthy_endpoints.go b/proxy/healthy_endpoints.go index b79a132769..20a6e7a656 100644 --- a/proxy/healthy_endpoints.go +++ b/proxy/healthy_endpoints.go @@ -11,7 +11,7 @@ type healthyEndpoints struct { endpointRegistry *routing.EndpointRegistry } -func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint, rt *routing.Route) []routing.LBEndpoint { +func (h *healthyEndpoints) filterHealthyEndpoints(ctx *context, endpoints []routing.LBEndpoint) []routing.LBEndpoint { if h == nil { return endpoints } @@ -20,8 +20,10 @@ func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint filtered := make([]routing.LBEndpoint, 0, len(endpoints)) for _, e := range endpoints { - if p < e.Metrics.HealthCheckDropProbability() { - /* drop */ + dropProbability := e.Metrics.HealthCheckDropProbability() + if p < dropProbability { + ctx.Logger().Infof("Dropping endpoint %q due to passive health check: p=%0.2f, dropProbability=%0.2f", + e.Host, p, dropProbability) } else { filtered = append(filtered, e) } diff --git a/proxy/proxy.go b/proxy/proxy.go index 6e0616530b..d11850141e 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -540,7 +540,7 @@ func (p *Proxy) selectEndpoint(ctx *context) *routing.LBEndpoint { rt := ctx.route endpoints := rt.LBEndpoints endpoints = p.fadein.filterFadeIn(endpoints, rt) - endpoints = p.heathlyEndpoints.filterHealthyEndpoints(endpoints, rt) + endpoints = p.heathlyEndpoints.filterHealthyEndpoints(ctx, endpoints) lbctx := &routing.LBContext{ Request: ctx.request, diff --git a/routing/endpointregistry.go b/routing/endpointregistry.go index e43cb7f867..539f7c8fc4 100644 --- a/routing/endpointregistry.go +++ b/routing/endpointregistry.go @@ -5,6 +5,8 @@ import ( "sync/atomic" "time" + log "github.com/sirupsen/logrus" + "github.com/zalando/skipper/eskip" ) @@ -166,6 +168,9 @@ func (r *EndpointRegistry) updateStats() { requests := e.totalRequests[curSlot].Load() if requests > r.minRequests { failedRoundTripsRatio := float64(failed) / float64(requests) + if failedRoundTripsRatio > 0.0 { + log.Infof("Passive health check: marking %q as unhealthy due to failed round trips ratio: %0.2f", key, failedRoundTripsRatio) + } e.healthCheckDropProbability.Store(min(failedRoundTripsRatio, r.maxHealthCheckDropProbability)) } else { e.healthCheckDropProbability.Store(0.0)