From b155591da6122fdbc24c92fa7bd345b82f2244f6 Mon Sep 17 00:00:00 2001 From: Alvaro Aleman Date: Tue, 19 Dec 2017 18:20:11 +0100 Subject: [PATCH] Simplify conditions in passing.go --- registry/consul/passing.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/registry/consul/passing.go b/registry/consul/passing.go index a8f66ec59..77ea71882 100644 --- a/registry/consul/passing.go +++ b/registry/consul/passing.go @@ -26,15 +26,18 @@ func passingServices(checks []*api.HealthCheck, status []string) []*api.HealthCh // then check whether the agent is still alive and both the // node and the service are not in maintenance mode. for _, c := range checks { - if c.CheckID == "serfHealth" && c.Node == svc.Node && c.Status == "critical" { + if c.Node != svc.Node { + continue + } + if c.CheckID == "serfHealth" && c.Status == "critical" { log.Printf("[DEBUG] consul: Skipping service %q since agent on node %q is down: %s", svc.ServiceID, svc.Node, c.Output) goto skip } - if c.CheckID == "_node_maintenance" && c.Node == svc.Node { + if c.CheckID == "_node_maintenance" { log.Printf("[DEBUG] consul: Skipping service %q since node %q is in maintenance mode: %s", svc.ServiceID, svc.Node, c.Output) goto skip } - if c.CheckID == "_service_maintenance:"+svc.ServiceID && c.Node == svc.Node && c.Status == "critical" { + if c.CheckID == "_service_maintenance:"+svc.ServiceID && c.Status == "critical" { log.Printf("[DEBUG] consul: Skipping service %q since it is in maintenance mode: %s", svc.ServiceID, c.Output) goto skip }