Skip to content

Commit

Permalink
[1.10.x] server: suppress spurious blocking query returns where multi…
Browse files Browse the repository at this point in the history
…ple config entries are involved

Backport of #12362 to 1.10.x

Conflicts:
- agent/consul/config_endpoint.go
- agent/consul/discovery_chain_endpoint_test.go
- agent/consul/intention_endpoint_test.go
- agent/consul/internal_endpoint.go
- agent/consul/internal_endpoint_test.go
- agent/consul/rpc.go
  • Loading branch information
rboyer committed Feb 25, 2022
1 parent 2193b6b commit ed73ad6
Show file tree
Hide file tree
Showing 16 changed files with 1,223 additions and 260 deletions.
3 changes: 3 additions & 0 deletions .changelog/12362.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
server: suppress spurious blocking query returns where multiple config entries are involved
```
4 changes: 4 additions & 0 deletions agent/configentry/config_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ func NewKindName(kind, name string, entMeta *structs.EnterpriseMeta) KindName {
ret.Normalize()
return ret
}

func NewKindNameForEntry(entry structs.ConfigEntry) KindName {
return NewKindName(entry.GetKind(), entry.GetName(), entry.GetEnterpriseMeta())
}
45 changes: 45 additions & 0 deletions agent/configentry/service_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package configentry

import (
"github.com/hashicorp/consul/agent/structs"
)

// ResolvedServiceConfigSet is a wrapped set of raw cross-referenced config
// entries necessary for the ConfigEntry.ResolveServiceConfig RPC process.
//
// None of these are defaulted.
type ResolvedServiceConfigSet struct {
ServiceDefaults map[structs.ServiceID]*structs.ServiceConfigEntry
GlobalProxy *structs.ProxyConfigEntry
}

func (r *ResolvedServiceConfigSet) IsEmpty() bool {
return len(r.ServiceDefaults) == 0 && r.GlobalProxy == nil
}

func (r *ResolvedServiceConfigSet) GetServiceDefaults(sid structs.ServiceID) *structs.ServiceConfigEntry {
if r.ServiceDefaults == nil {
return nil
}
return r.ServiceDefaults[sid]
}

func (r *ResolvedServiceConfigSet) AddServiceDefaults(entry *structs.ServiceConfigEntry) {
if entry == nil {
return
}

if r.ServiceDefaults == nil {
r.ServiceDefaults = make(map[structs.ServiceID]*structs.ServiceConfigEntry)
}

sid := structs.NewServiceID(entry.Name, &entry.EnterpriseMeta)
r.ServiceDefaults[sid] = entry
}

func (r *ResolvedServiceConfigSet) AddProxyDefaults(entry *structs.ProxyConfigEntry) {
if entry == nil {
return
}
r.GlobalProxy = entry
}
Loading

0 comments on commit ed73ad6

Please sign in to comment.