Skip to content

Commit 8443058

Browse files
committed
updates based on reviews
1 parent bb64a68 commit 8443058

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

internal/mode/static/state/graph/route_common.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,12 @@ func isolateHostnamesForParentRefs(parentRef []ParentRef, listenerHostnameMap ma
420420
continue
421421
}
422422

423-
// for L4Routes, we only compare the hostname and listener name combination
424-
// because we do not allow l4Routes to attach to the same listener
425-
// if they share the same port and hostname.
423+
// for L7Routes, we compare the hostname, port and listener name combination
424+
// to identify if hostname needs to be isolated.
426425
if h == lHostPort.hostname && listenerName != lName {
426+
// for L4Routes, we only compare the hostname and listener name combination
427+
// because we do not allow l4Routes to attach to the same listener
428+
// if they share the same port and hostname.
427429
if isL4Route || lHostPort.port == ref.Attachment.ListenerPort {
428430
hostnamesToRemoves[h] = struct{}{}
429431
}

internal/mode/static/state/graph/route_common_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,8 @@ func TestIsolateL4Listeners(t *testing.T) {
24442444
"tls_flavor": {"flavor.example.com"},
24452445
}
24462446

2447+
hostnamesNoSectionName := []gatewayv1.Hostname{"tea.example.com", "coffee.example.com", "flavor.example.com"}
2448+
24472449
tests := []struct {
24482450
expectedResult map[string][]ParentRef
24492451
listenerMap map[string]hostPort
@@ -2462,21 +2464,21 @@ func TestIsolateL4Listeners(t *testing.T) {
24622464
createL4RoutewithAcceptedHostnames(
24632465
tlsCoffeeRoute,
24642466
acceptedHostnamesNoSectionName,
2465-
[]gatewayv1.Hostname{"coffee.example.com"},
2467+
hostnamesNoSectionName,
24662468
nil, // no section name
24672469
443,
24682470
),
24692471
createL4RoutewithAcceptedHostnames(
24702472
tlsTeaRoute,
24712473
acceptedHostnamesNoSectionName,
2472-
[]gatewayv1.Hostname{"tea.example.com"},
2474+
hostnamesNoSectionName,
24732475
nil, // no section name
24742476
443,
24752477
),
24762478
createL4RoutewithAcceptedHostnames(
24772479
tlsFlavorRoute,
24782480
acceptedHostnamesNoSectionName,
2479-
[]gatewayv1.Hostname{"flavor.example.com"},
2481+
hostnamesNoSectionName,
24802482
nil, // no section name
24812483
443,
24822484
),
@@ -2834,6 +2836,8 @@ func TestIsolateL7Listeners(t *testing.T) {
28342836
"hr_flavor": {"flavor.example.com"},
28352837
}
28362838

2839+
hostnamesNoSectionName := []gatewayv1.Hostname{"tea.example.com", "coffee.example.com", "flavor.example.com"}
2840+
28372841
tests := []struct {
28382842
expectedResult map[string][]ParentRef
28392843
listenersMap map[string]hostPort
@@ -2884,21 +2888,21 @@ func TestIsolateL7Listeners(t *testing.T) {
28842888
createL7RoutewithAcceptedHostnames(
28852889
hrCoffeeRoute,
28862890
acceptedHostnamesNoSectionName,
2887-
[]gatewayv1.Hostname{"coffee.example.com"},
2891+
hostnamesNoSectionName,
28882892
nil, // no section name
28892893
80,
28902894
),
28912895
createL7RoutewithAcceptedHostnames(
28922896
hrTeaRoute,
28932897
acceptedHostnamesNoSectionName,
2894-
[]gatewayv1.Hostname{"tea.example.com"},
2898+
hostnamesNoSectionName,
28952899
nil, // no section name
28962900
80,
28972901
),
28982902
createL7RoutewithAcceptedHostnames(
28992903
hrFlavorRoute,
29002904
acceptedHostnamesNoSectionName,
2901-
[]gatewayv1.Hostname{"flavor.example.com"},
2905+
hostnamesNoSectionName,
29022906
nil, // no section name
29032907
80,
29042908
),

0 commit comments

Comments
 (0)