Skip to content

Commit

Permalink
[1.17.0 manual backport] mesh: ensure route configs are named uniquel…
Browse files Browse the repository at this point in the history
…y per port (#19325)

mesh: ensure route configs are named uniquely per port (#19323)
  • Loading branch information
ishustava committed Oct 23, 2023
1 parent bdcfbea commit c20aa58
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
Expand All @@ -265,7 +265,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app2"
"name": "default/local/default/api-app2:http"
},
"statPrefix": "upstream."
},
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
Expand Down Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
{
"l7": {
"route": {
"name": "default/local/default/api-app"
"name": "default/local/default/api-app:http"
},
"statPrefix": "upstream."
},
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit c20aa58

Please sign in to comment.