mirror of https://github.com/hashicorp/consul
Gather instance counts of aggregated services (#7415)
parent
ba9849bdf8
commit
e3891db55b
|
@ -21,6 +21,7 @@ type ServiceSummary struct {
|
||||||
Name string
|
Name string
|
||||||
Tags []string
|
Tags []string
|
||||||
Nodes []string
|
Nodes []string
|
||||||
|
InstanceCount int
|
||||||
ChecksPassing int
|
ChecksPassing int
|
||||||
ChecksWarning int
|
ChecksWarning int
|
||||||
ChecksCritical int
|
ChecksCritical int
|
||||||
|
@ -165,6 +166,9 @@ func summarizeServices(dump structs.CheckServiceNodes) []*ServiceSummary {
|
||||||
serv = &ServiceSummary{
|
serv = &ServiceSummary{
|
||||||
Name: service.ID,
|
Name: service.ID,
|
||||||
EnterpriseMeta: service.EnterpriseMeta,
|
EnterpriseMeta: service.EnterpriseMeta,
|
||||||
|
// the other code will increment this unconditionally so we
|
||||||
|
// shouldn't initialize it to 1
|
||||||
|
InstanceCount: 0,
|
||||||
}
|
}
|
||||||
summary[service] = serv
|
summary[service] = serv
|
||||||
services = append(services, service)
|
services = append(services, service)
|
||||||
|
@ -179,6 +183,7 @@ func summarizeServices(dump structs.CheckServiceNodes) []*ServiceSummary {
|
||||||
sum := getService(sid)
|
sum := getService(sid)
|
||||||
sum.Nodes = append(sum.Nodes, csn.Node.Node)
|
sum.Nodes = append(sum.Nodes, csn.Node.Node)
|
||||||
sum.Kind = svc.Kind
|
sum.Kind = svc.Kind
|
||||||
|
sum.InstanceCount += 1
|
||||||
for _, tag := range svc.Tags {
|
for _, tag := range svc.Tags {
|
||||||
found := false
|
found := false
|
||||||
for _, existing := range sum.Tags {
|
for _, existing := range sum.Tags {
|
||||||
|
|
|
@ -322,6 +322,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "api",
|
Name: "api",
|
||||||
Tags: []string{"tag1", "tag2"},
|
Tags: []string{"tag1", "tag2"},
|
||||||
Nodes: []string{"foo"},
|
Nodes: []string{"foo"},
|
||||||
|
InstanceCount: 1,
|
||||||
ChecksPassing: 2,
|
ChecksPassing: 2,
|
||||||
ChecksWarning: 1,
|
ChecksWarning: 1,
|
||||||
ChecksCritical: 0,
|
ChecksCritical: 0,
|
||||||
|
@ -332,6 +333,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "cache",
|
Name: "cache",
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
Nodes: []string{"zip"},
|
Nodes: []string{"zip"},
|
||||||
|
InstanceCount: 1,
|
||||||
ChecksPassing: 0,
|
ChecksPassing: 0,
|
||||||
ChecksWarning: 0,
|
ChecksWarning: 0,
|
||||||
ChecksCritical: 0,
|
ChecksCritical: 0,
|
||||||
|
@ -342,6 +344,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "web",
|
Name: "web",
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
Nodes: []string{"bar", "foo"},
|
Nodes: []string{"bar", "foo"},
|
||||||
|
InstanceCount: 2,
|
||||||
ChecksPassing: 2,
|
ChecksPassing: 2,
|
||||||
ChecksWarning: 1,
|
ChecksWarning: 1,
|
||||||
ChecksCritical: 1,
|
ChecksCritical: 1,
|
||||||
|
@ -353,6 +356,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "consul",
|
Name: "consul",
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
Nodes: []string{a.Config.NodeName},
|
Nodes: []string{a.Config.NodeName},
|
||||||
|
InstanceCount: 1,
|
||||||
ChecksPassing: 1,
|
ChecksPassing: 1,
|
||||||
ChecksWarning: 0,
|
ChecksWarning: 0,
|
||||||
ChecksCritical: 0,
|
ChecksCritical: 0,
|
||||||
|
@ -385,6 +389,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "api",
|
Name: "api",
|
||||||
Tags: []string{"tag1", "tag2"},
|
Tags: []string{"tag1", "tag2"},
|
||||||
Nodes: []string{"foo"},
|
Nodes: []string{"foo"},
|
||||||
|
InstanceCount: 1,
|
||||||
ChecksPassing: 2,
|
ChecksPassing: 2,
|
||||||
ChecksWarning: 1,
|
ChecksWarning: 1,
|
||||||
ChecksCritical: 0,
|
ChecksCritical: 0,
|
||||||
|
@ -395,6 +400,7 @@ func TestUiServices(t *testing.T) {
|
||||||
Name: "web",
|
Name: "web",
|
||||||
Tags: nil,
|
Tags: nil,
|
||||||
Nodes: []string{"bar", "foo"},
|
Nodes: []string{"bar", "foo"},
|
||||||
|
InstanceCount: 2,
|
||||||
ChecksPassing: 2,
|
ChecksPassing: 2,
|
||||||
ChecksWarning: 1,
|
ChecksWarning: 1,
|
||||||
ChecksCritical: 1,
|
ChecksCritical: 1,
|
||||||
|
|
Loading…
Reference in New Issue