Skip to content

Commit

Permalink
Merge pull request #9436 from hashicorp/dnephin/fix-service-health-re…
Browse files Browse the repository at this point in the history
…q-cache-key

structs: fix caching of ServiceSpecificRequest when ingress=true
  • Loading branch information
dnephin authored Jan 14, 2021
2 parents 8fdc789 + 29ce5ec commit 964ab23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changelog/9436.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:bug
cache: Fixed a bug where a DNS or API request for an ingress gateway would incorrectly
return a cached result for a service request with the same name, and vice versa.
``
1 change: 1 addition & 0 deletions agent/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ func (r *ServiceSpecificRequest) CacheInfo() cache.RequestInfo {
r.Connect,
r.Filter,
r.EnterpriseMeta,
r.Ingress,
}, nil)
if err == nil {
// If there is an error, we don't set the key. A blank key forces
Expand Down
12 changes: 10 additions & 2 deletions agent/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,6 @@ func TestServiceSpecificRequestCacheInfoKey(t *testing.T) {
ignoredFields := map[string]bool{
// TODO: should this filed be included?
"ServiceKind": true,
// TODO: this filed should be included: github.com/hashicorp/consul/pull/9436
"Ingress": true,
}

assertCacheInfoKeyIsComplete(t, &ServiceSpecificRequest{}, ignoredFields)
Expand Down Expand Up @@ -1715,6 +1713,16 @@ func TestSpecificServiceRequest_CacheInfo(t *testing.T) {
},
wantSame: false,
},
{
name: "with integress=true",
req: ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: "my-service",
},
mutate: func(req *ServiceSpecificRequest) {
req.Ingress = true
},
},
}

for _, tc := range tests {
Expand Down

0 comments on commit 964ab23

Please sign in to comment.