-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.11.x] server: suppress spurious blocking query returns where multi…
…ple config entries are involved Backport of #12362 to 1.11.x Conflicts: - agent/consul/config_endpoint_test.go (imports) - go.mod (adjacencies)
- Loading branch information
Showing
16 changed files
with
1,225 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 | ||
ProxyDefaults map[string]*structs.ProxyConfigEntry | ||
} | ||
|
||
func (r *ResolvedServiceConfigSet) IsEmpty() bool { | ||
return len(r.ServiceDefaults) == 0 && len(r.ProxyDefaults) == 0 | ||
} | ||
|
||
func (r *ResolvedServiceConfigSet) GetServiceDefaults(sid structs.ServiceID) *structs.ServiceConfigEntry { | ||
if r.ServiceDefaults == nil { | ||
return nil | ||
} | ||
return r.ServiceDefaults[sid] | ||
} | ||
|
||
func (r *ResolvedServiceConfigSet) GetProxyDefaults(partition string) *structs.ProxyConfigEntry { | ||
if r.ProxyDefaults == nil { | ||
return nil | ||
} | ||
return r.ProxyDefaults[partition] | ||
} | ||
|
||
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 | ||
} | ||
|
||
if r.ProxyDefaults == nil { | ||
r.ProxyDefaults = make(map[string]*structs.ProxyConfigEntry) | ||
} | ||
|
||
r.ProxyDefaults[entry.PartitionOrDefault()] = entry | ||
} |
Oops, something went wrong.