From 6ba4114be87362972567b051939dbfbcf70083c2 Mon Sep 17 00:00:00 2001 From: Jakub Jarosz Date: Tue, 15 Nov 2022 11:19:34 +0000 Subject: [PATCH] Round flow to the left --- internal/healthcheck/healthcheck.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/healthcheck/healthcheck.go b/internal/healthcheck/healthcheck.go index dba6bc5af1..375cf7e001 100644 --- a/internal/healthcheck/healthcheck.go +++ b/internal/healthcheck/healthcheck.go @@ -177,16 +177,18 @@ type HostStats struct { func countStats(upstreams *client.Upstreams, upstreamNames []string) HostStats { total, up := 0, 0 for name, u := range *upstreams { - if slices.Contains(upstreamNames, name) { - for _, p := range u.Peers { - total++ - if strings.ToLower(p.State) != "up" { - continue - } - up++ + if !slices.Contains(upstreamNames, name) { + continue + } + for _, p := range u.Peers { + total++ + if strings.ToLower(p.State) != "up" { + continue } + up++ } } + unhealthy := total - up return HostStats{ Total: total,