mirror of https://github.com/status-im/consul.git
Do not filter tags unless req.TagFilter is set
Send empty array [] instead of [""] in DNS requests when TagFilter is not set Do not change case sensitivity of services anymore in `getServiceNodes()` since cache keys are now case insensitive
This commit is contained in:
parent
6f91085869
commit
5bee19ee16
|
@ -1171,12 +1171,16 @@ func (d *DNSServer) trimDNSResponse(cfg *dnsConfig, network string, req, resp *d
|
|||
|
||||
// lookupServiceNodes returns nodes with a given service.
|
||||
func (d *DNSServer) lookupServiceNodes(cfg *dnsConfig, lookup serviceLookup) (structs.IndexedCheckServiceNodes, error) {
|
||||
serviceTags := []string{}
|
||||
if lookup.Tag != "" {
|
||||
serviceTags = []string{lookup.Tag}
|
||||
}
|
||||
args := structs.ServiceSpecificRequest{
|
||||
Connect: lookup.Connect,
|
||||
Ingress: lookup.Ingress,
|
||||
Datacenter: lookup.Datacenter,
|
||||
ServiceName: lookup.Service,
|
||||
ServiceTags: []string{lookup.Tag},
|
||||
ServiceTags: serviceTags,
|
||||
TagFilter: lookup.Tag != "",
|
||||
QueryOptions: structs.QueryOptions{
|
||||
Token: d.agent.tokens.UserToken(),
|
||||
|
|
|
@ -50,7 +50,6 @@ func (c *Client) getServiceNodes(
|
|||
) (structs.IndexedCheckServiceNodes, cache.ResultMeta, error) {
|
||||
var out structs.IndexedCheckServiceNodes
|
||||
|
||||
req.ServiceName = strings.ToLower(req.ServiceName)
|
||||
if !req.QueryOptions.UseCache {
|
||||
err := c.NetRPC.RPC("Health.ServiceNodes", &req, &out)
|
||||
return out, cache.ResultMeta{}, err
|
||||
|
@ -75,19 +74,12 @@ func (c *Client) getServiceNodes(
|
|||
}
|
||||
|
||||
func filterTags(out *structs.IndexedCheckServiceNodes, req structs.ServiceSpecificRequest) structs.IndexedCheckServiceNodes {
|
||||
if len(req.ServiceTags) == 0 || len(out.Nodes) == 0 {
|
||||
if !req.TagFilter || len(req.ServiceTags) == 0 || len(out.Nodes) == 0 {
|
||||
return *out
|
||||
}
|
||||
tags := make([]string, 0, len(req.ServiceTags))
|
||||
for _, r := range req.ServiceTags {
|
||||
// DNS has the bad habit to setting [""] for ServiceTags
|
||||
if r != "" {
|
||||
tags = append(tags, strings.ToLower(r))
|
||||
}
|
||||
}
|
||||
// No need to filter
|
||||
if len(tags) == 0 {
|
||||
return *out
|
||||
tags = append(tags, strings.ToLower(r))
|
||||
}
|
||||
results := make(structs.CheckServiceNodes, 0, len(out.Nodes))
|
||||
for _, service := range out.Nodes {
|
||||
|
|
Loading…
Reference in New Issue