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 <aroradaman@gmail.com>
This commit is contained in:
Daman Arora 2025-01-10 21:20:46 +05:30
parent 0645f0e50e
commit 64aac665fd

View File

@ -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
}