Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(egress): same external service tag in multiple meshes (backport of #11667) #11670

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -18,6 +18,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 @@ -149,8 +150,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 @@ -219,5 +220,9 @@ var _ = Describe("EgressGenerator", func() {
fileWithResourcesName: "subsets-with-external-meshhttproute.yaml",
expected: "subsets-with-external-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
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
Loading