Skip to content

Commit

Permalink
fix(egress): same external service tag in multiple meshes (#11667)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
jakubdyszkiewicz committed Oct 6, 2024
1 parent 1f0facd commit a990fa8
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/xds/generator/egress/external_services_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (*ExternalServicesGenerator) generateCDS(
}

resources = append(resources, &core_xds.Resource{
Name: serviceName,
Name: cluster.GetName(),
Origin: OriginEgress,
Resource: cluster,
})
Expand Down
9 changes: 7 additions & 2 deletions pkg/xds/generator/egress/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
meshhttproute_api "github.com/kumahq/kuma/pkg/plugins/policies/meshhttproute/api/v1alpha1"
. "github.com/kumahq/kuma/pkg/test/matchers"
"github.com/kumahq/kuma/pkg/test/xds"
"github.com/kumahq/kuma/pkg/util/maps"
util_proto "github.com/kumahq/kuma/pkg/util/proto"
xds_context "github.com/kumahq/kuma/pkg/xds/context"
envoy_common "github.com/kumahq/kuma/pkg/xds/envoy"
Expand Down Expand Up @@ -150,8 +151,8 @@ var _ = Describe("EgressGenerator", func() {
}

var meshResourcesList []*core_xds.MeshResources
for _, meshResources := range meshResourcesMap {
meshResourcesList = append(meshResourcesList, meshResources)
for _, meshName := range maps.SortedKeys(meshResourcesMap) {
meshResourcesList = append(meshResourcesList, meshResourcesMap[meshName])
}

proxy := &core_xds.Proxy{
Expand Down Expand Up @@ -216,5 +217,9 @@ var _ = Describe("EgressGenerator", func() {
fileWithResourcesName: "subsets-with-meshhttproute.yaml",
expected: "subsets-with-meshhttproute.golden.yaml",
}),
Entry("same kuma.io/service", testCase{
fileWithResourcesName: "same-kuma-io-service.yaml",
expected: "same-kuma-io-service.golden.yaml",
}),
)
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- name: externalservice-1
- name: mesh-1:externalservice-1
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- name: externalservice-1
- name: mesh-1:externalservice-1
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-1
Expand Down Expand Up @@ -30,7 +30,7 @@ resources:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
httpProtocolOptions: {}
- name: externalservice-2
- name: mesh-1:externalservice-2
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- name: externalservice-1
- name: mesh-1:externalservice-1
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-1
Expand Down Expand Up @@ -30,7 +30,7 @@ resources:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
httpProtocolOptions: {}
- name: externalservice-2
- name: mesh-1:externalservice-2
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- name: externalservice-1
- name: mesh-1:externalservice-1
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-1
Expand Down Expand Up @@ -30,7 +30,7 @@ resources:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
httpProtocolOptions: {}
- name: externalservice-2
- name: mesh-1:externalservice-2
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- name: externalservice-1
- name: mesh-1:externalservice-1
resource:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
altStatName: mesh-1_externalservice-1
Expand Down
90 changes: 90 additions & 0 deletions pkg/xds/generator/egress/testdata/input/same-kuma-io-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
type: ZoneEgress
name: zoneegress-1
zone: zone-1
networking:
address: 192.168.0.1
port: 10002
---
type: Mesh
name: mesh-1
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: builtin
---
type: TrafficPermission
name: allow-all-traffic-1
mesh: mesh-1
sources:
- match:
kuma.io/service: '*'
destinations:
- match:
kuma.io/service: '*'
---
type: TrafficRoute
name: trafficroute-1
mesh: mesh-1
sources:
- match:
kuma.io/service: "*"
destinations:
- match:
kuma.io/service: "*"
conf:
loadBalancer:
roundRobin: {}
destination:
kuma.io/service: "*"
---
type: ExternalService
name: externalservice-1
mesh: mesh-1
tags:
kuma.io/service: externalservice # same kuma.io/service
kuma.io/protocol: http
networking:
address: kuma.io:80
---
type: Mesh
name: mesh-2
mtls:
enabledBackend: ca-1
backends:
- name: ca-1
type: builtin
---
type: TrafficPermission
name: allow-all-traffic-2
mesh: mesh-2
sources:
- match:
kuma.io/service: '*'
destinations:
- match:
kuma.io/service: '*'
---
type: TrafficRoute
name: trafficroute-2
mesh: mesh-2
sources:
- match:
kuma.io/service: "*"
destinations:
- match:
kuma.io/service: "*"
conf:
loadBalancer:
roundRobin: {}
destination:
kuma.io/service: "*"
---
type: ExternalService
name: externalservice-2
mesh: mesh-2
tags:
kuma.io/service: externalservice # same kuma.io/service
kuma.io/protocol: http
networking:
address: kuma.io:80
Loading

0 comments on commit a990fa8

Please sign in to comment.