mesh: ensure route configs are named uniquely per port (#19323)

This commit is contained in:
Iryna Shustava 2023-10-20 16:59:18 -06:00 committed by GitHub
parent 27f649c4ba
commit 809bf1deb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 18 deletions

View File

@ -94,7 +94,7 @@ func (b *Builder) buildDestination(
if destination.Explicit != nil {
routeName = lb.listener.Name
} else {
routeName = DestinationResourceID(cpr.ParentRef.Ref)
routeName = DestinationResourceID(cpr.ParentRef.Ref, cpr.ParentRef.Port)
}
var (

View File

@ -29,7 +29,7 @@ func DestinationStatPrefix(serviceRef *pbresource.Reference, portName, datacente
}
func DestinationListenerName(destinationRef *pbresource.Reference, portName string, address string, port uint32) string {
name := fmt.Sprintf("%s:%s:%s", DestinationResourceID(destinationRef), portName, address)
name := fmt.Sprintf("%s:%s", DestinationResourceID(destinationRef, portName), address)
if port != 0 {
return fmt.Sprintf("%s:%d", name, port)
}
@ -39,8 +39,8 @@ func DestinationListenerName(destinationRef *pbresource.Reference, portName stri
// DestinationResourceID returns a string representation that uniquely identifies the
// upstream in a canonical but human readable way.
func DestinationResourceID(destinationRef *pbresource.Reference) string {
func DestinationResourceID(destinationRef *pbresource.Reference, port string) string {
tenancyPrefix := fmt.Sprintf("%s/%s/%s", destinationRef.Tenancy.Partition,
destinationRef.Tenancy.PeerName, destinationRef.Tenancy.Namespace)
return fmt.Sprintf("%s/%s", tenancyPrefix, destinationRef.Name)
return fmt.Sprintf("%s/%s:%s", tenancyPrefix, destinationRef.Name, port)
}

View File

@ -248,7 +248,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
@ -265,7 +265,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app2"
"name": "default/local/default/api-app2:http"
},
"statPrefix": "upstream."
},
@ -325,18 +325,18 @@
}
],
"routes": {
"default/local/default/api-app": {
"default/local/default/api-app2:http": {
"virtualHosts": [
{
"domains": [
"*"
],
"name": "default/local/default/api-app",
"name": "default/local/default/api-app2:http",
"routeRules": [
{
"destination": {
"cluster": {
"name": "http.api-app.default.dc1.internal.foo.consul"
"name": "http.api-app2.default.dc1.internal.foo.consul"
}
},
"match": {
@ -349,18 +349,18 @@
}
]
},
"default/local/default/api-app2": {
"default/local/default/api-app:http": {
"virtualHosts": [
{
"domains": [
"*"
],
"name": "default/local/default/api-app2",
"name": "default/local/default/api-app:http",
"routeRules": [
{
"destination": {
"cluster": {
"name": "http.api-app2.default.dc1.internal.foo.consul"
"name": "http.api-app.default.dc1.internal.foo.consul"
}
},
"match": {

View File

@ -146,7 +146,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
@ -181,13 +181,13 @@
}
],
"routes": {
"default/local/default/api-app": {
"default/local/default/api-app:http": {
"virtualHosts": [
{
"domains": [
"*"
],
"name": "default/local/default/api-app",
"name": "default/local/default/api-app:http",
"routeRules": [
{
"destination": {

View File

@ -146,7 +146,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
@ -181,13 +181,13 @@
}
],
"routes": {
"default/local/default/api-app": {
"default/local/default/api-app:http": {
"virtualHosts": [
{
"domains": [
"*"
],
"name": "default/local/default/api-app",
"name": "default/local/default/api-app:http",
"routeRules": [
{
"destination": {