diff --git a/command/agent/dns.go b/command/agent/dns.go index da5312d31..70e76648c 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -384,6 +384,7 @@ func (d *DNSServer) filterServiceNodes(nodes structs.CheckServiceNodes) structs. node.Node.Node, check.CheckID, check.Name, node.Service.Service) nodes[i], nodes[n-1] = nodes[n-1], structs.CheckServiceNode{} n-- + i-- } } } diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index 1ff478dd3..c2aa000ea 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -332,7 +332,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) { // Wait for leader time.Sleep(100 * time.Millisecond) - // Register node + // Register nodes args := &structs.RegisterRequest{ Datacenter: "dc1", Node: "foo", @@ -353,6 +353,25 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) { t.Fatalf("err: %v", err) } + args2 := &structs.RegisterRequest{ + Datacenter: "dc1", + Node: "bar", + Address: "127.0.0.2", + Service: &structs.NodeService{ + Service: "db", + Tag: "master", + Port: 12345, + }, + Check: &structs.HealthCheck{ + CheckID: "serf", + Name: "serf", + Status: structs.HealthCritical, + }, + } + if err := srv.agent.RPC("Catalog.Register", args2, &out); err != nil { + t.Fatalf("err: %v", err) + } + m := new(dns.Msg) m.SetQuestion("db.service.consul.", dns.TypeANY)