From 64aac665fd98e2995a4fdcf3628b8ed10c63e324 Mon Sep 17 00:00:00 2001 From: Daman Arora Date: Fri, 10 Jan 2025 21:20:46 +0530 Subject: [PATCH] pkg/proxy/healthcheck: bug fix for last updated time The lastUpdated time returned by healthz call should be the latest lastUpdated time among the proxiers. Prior to this commit, if proxy is unhealthy, the returned lastUpdated time was lastUpdated time of the unhealthy proxier. Signed-off-by: Daman Arora --- pkg/proxy/healthcheck/proxy_health.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/proxy/healthcheck/proxy_health.go b/pkg/proxy/healthcheck/proxy_health.go index bb61adf22dc..652f7ef90dc 100644 --- a/pkg/proxy/healthcheck/proxy_health.go +++ b/pkg/proxy/healthcheck/proxy_health.go @@ -113,14 +113,14 @@ func (hs *ProxyHealthServer) isHealthy() (bool, time.Time) { defer hs.lock.RUnlock() var lastUpdated time.Time - currentTime := hs.clock.Now() - - for ipFamily, proxierLastUpdated := range hs.lastUpdatedMap { - + for _, proxierLastUpdated := range hs.lastUpdatedMap { if proxierLastUpdated.After(lastUpdated) { lastUpdated = proxierLastUpdated } + } + currentTime := hs.clock.Now() + for ipFamily, _ := range hs.lastUpdatedMap { if _, set := hs.oldestPendingQueuedMap[ipFamily]; !set { // the proxier is healthy while it's starting up // or the proxier is fully synced. @@ -131,7 +131,7 @@ func (hs *ProxyHealthServer) isHealthy() (bool, time.Time) { // there's an unprocessed update queued for this proxier, but it's not late yet. continue } - return false, proxierLastUpdated + return false, lastUpdated } return true, lastUpdated }