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))
for _, candidate := range allServices {
if candidate.Name == structs.ConsulServiceName {
continue
}
decision, err := s.IntentionDecision(candidate.Name, candidate.NamespaceOrDefault(), intentions, decisionMatchType, defaultDecision, true)
if err != nil {
src, dst := target, candidate

View File

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