agent: Fixing bug in dns service filtering
This commit is contained in:
parent
38317d4890
commit
8fdbf95452
|
@ -384,6 +384,7 @@ func (d *DNSServer) filterServiceNodes(nodes structs.CheckServiceNodes) structs.
|
||||||
node.Node.Node, check.CheckID, check.Name, node.Service.Service)
|
node.Node.Node, check.CheckID, check.Name, node.Service.Service)
|
||||||
nodes[i], nodes[n-1] = nodes[n-1], structs.CheckServiceNode{}
|
nodes[i], nodes[n-1] = nodes[n-1], structs.CheckServiceNode{}
|
||||||
n--
|
n--
|
||||||
|
i--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
||||||
// Wait for leader
|
// Wait for leader
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
// Register node
|
// Register nodes
|
||||||
args := &structs.RegisterRequest{
|
args := &structs.RegisterRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
|
@ -353,6 +353,25 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
||||||
t.Fatalf("err: %v", err)
|
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 := new(dns.Msg)
|
||||||
m.SetQuestion("db.service.consul.", dns.TypeANY)
|
m.SetQuestion("db.service.consul.", dns.TypeANY)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue