Add information about which services are proxied to ui services… (#7417)
This commit is contained in:
parent
a8961e37d9
commit
ac78be97f4
|
@ -22,6 +22,8 @@ type ServiceSummary struct {
|
|||
Tags []string
|
||||
Nodes []string
|
||||
InstanceCount int
|
||||
ProxyFor []string `json:",omitempty"`
|
||||
proxyForSet map[string]struct{} // internal to track uniqueness
|
||||
ChecksPassing int
|
||||
ChecksWarning int
|
||||
ChecksCritical int
|
||||
|
@ -184,6 +186,15 @@ func summarizeServices(dump structs.CheckServiceNodes) []*ServiceSummary {
|
|||
sum.Nodes = append(sum.Nodes, csn.Node.Node)
|
||||
sum.Kind = svc.Kind
|
||||
sum.InstanceCount += 1
|
||||
if svc.Kind == structs.ServiceKindConnectProxy {
|
||||
if _, ok := sum.proxyForSet[svc.Proxy.DestinationServiceName]; !ok {
|
||||
if sum.proxyForSet == nil {
|
||||
sum.proxyForSet = make(map[string]struct{})
|
||||
}
|
||||
sum.proxyForSet[svc.Proxy.DestinationServiceName] = struct{}{}
|
||||
sum.ProxyFor = append(sum.ProxyFor, svc.Proxy.DestinationServiceName)
|
||||
}
|
||||
}
|
||||
for _, tag := range svc.Tags {
|
||||
found := false
|
||||
for _, existing := range sum.Tags {
|
||||
|
|
|
@ -314,6 +314,7 @@ func TestUiServices(t *testing.T) {
|
|||
// internal accounting that users don't see can be blown away
|
||||
for _, sum := range summary {
|
||||
sum.externalSourceSet = nil
|
||||
sum.proxyForSet = nil
|
||||
}
|
||||
|
||||
expected := []*ServiceSummary{
|
||||
|
@ -345,6 +346,7 @@ func TestUiServices(t *testing.T) {
|
|||
Tags: nil,
|
||||
Nodes: []string{"bar", "foo"},
|
||||
InstanceCount: 2,
|
||||
ProxyFor: []string{"api"},
|
||||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 1,
|
||||
|
@ -381,6 +383,7 @@ func TestUiServices(t *testing.T) {
|
|||
// internal accounting that users don't see can be blown away
|
||||
for _, sum := range summary {
|
||||
sum.externalSourceSet = nil
|
||||
sum.proxyForSet = nil
|
||||
}
|
||||
|
||||
expected := []*ServiceSummary{
|
||||
|
@ -401,6 +404,7 @@ func TestUiServices(t *testing.T) {
|
|||
Tags: nil,
|
||||
Nodes: []string{"bar", "foo"},
|
||||
InstanceCount: 2,
|
||||
ProxyFor: []string{"api"},
|
||||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 1,
|
||||
|
|
Loading…
Reference in New Issue