Do not include consul as upstream or downstream

This commit is contained in:
freddygv 2021-03-17 13:40:04 -06:00
parent 3f2489c31d
commit 37f684664d
2 changed files with 15 additions and 7 deletions

View File

@ -1001,6 +1001,9 @@ func (s *Store) IntentionTopology(ws memdb.WatchSet,
} }
result := make(structs.ServiceList, 0, len(allServices)) result := make(structs.ServiceList, 0, len(allServices))
for _, candidate := range allServices { for _, candidate := range allServices {
if candidate.Name == structs.ConsulServiceName {
continue
}
decision, err := s.IntentionDecision(candidate.Name, candidate.NamespaceOrDefault(), intentions, decisionMatchType, defaultDecision, true) decision, err := s.IntentionDecision(candidate.Name, candidate.NamespaceOrDefault(), intentions, decisionMatchType, defaultDecision, true)
if err != nil { if err != nil {
src, dst := target, candidate src, dst := target, candidate

View File

@ -1889,6 +1889,11 @@ func TestStore_IntentionTopology(t *testing.T) {
Address: "127.0.0.1", Address: "127.0.0.1",
} }
services := []structs.NodeService{ services := []structs.NodeService{
{
ID: structs.ConsulServiceID,
Service: structs.ConsulServiceName,
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
},
{ {
ID: "api-1", ID: "api-1",
Service: "api", Service: "api",
@ -1960,7 +1965,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("web", nil), target: structs.NewServiceName("web", nil),
downstreams: false, downstreams: false,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "mysql", Name: "mysql",
@ -1987,7 +1992,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("web", nil), target: structs.NewServiceName("web", nil),
downstreams: false, downstreams: false,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "api", Name: "api",
@ -2014,7 +2019,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("api", nil), target: structs.NewServiceName("api", nil),
downstreams: true, downstreams: true,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "ingress-gateway", Name: "ingress-gateway",
@ -2045,7 +2050,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("api", nil), target: structs.NewServiceName("api", nil),
downstreams: true, downstreams: true,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "web", Name: "web",
@ -2072,7 +2077,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("web", nil), target: structs.NewServiceName("web", nil),
downstreams: false, downstreams: false,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "api", Name: "api",
@ -2103,7 +2108,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("web", nil), target: structs.NewServiceName("web", nil),
downstreams: false, downstreams: false,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{}, services: structs.ServiceList{},
}, },
}, },
@ -2125,7 +2130,7 @@ func TestStore_IntentionTopology(t *testing.T) {
target: structs.NewServiceName("web", nil), target: structs.NewServiceName("web", nil),
downstreams: false, downstreams: false,
expect: expect{ expect: expect{
idx: 9, idx: 10,
services: structs.ServiceList{ services: structs.ServiceList{
{ {
Name: "api", Name: "api",