Skip to content

Commit d2f7d45

Browse files
committed
Add some function comments
1 parent cbed859 commit d2f7d45

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/controller/state/graph/policies.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,12 @@ func checkTargetRoutesForOverlap(
325325
func checkForRouteOverlap(route *L7Route, hostPortPaths map[string]string) *conditions.Condition {
326326
for _, parentRef := range route.ParentRefs {
327327
if parentRef.Attachment != nil {
328-
// fmt.Printf("This is the parentRef attachment: %#v\n", parentRef.Attachment)
329328
port := parentRef.Attachment.ListenerPort
330329
for _, hostname := range parentRef.Attachment.AcceptedHostnames {
331-
// fmt.Println("Here is the keyName: " + keyName)
332-
// fmt.Printf("This is the parentref hostnames: %v\n", hostname)
333330
for _, rule := range route.Spec.Rules {
334-
// fmt.Printf("This is the routeRule: %v\n", rule)
335331
for _, match := range rule.Matches {
336-
// fmt.Printf("This is the match: %v\n", match)
337332
if match.Path != nil && match.Path.Value != nil {
338333
key := fmt.Sprintf("%s:%d%s", hostname, port, *match.Path.Value)
339-
// fmt.Println("This is the key: " + key)
340334
if val, ok := hostPortPaths[key]; !ok {
341335
hostPortPaths[key] = fmt.Sprintf("%s/%s", route.Source.GetNamespace(), route.Source.GetName())
342336
} else {

internal/controller/status/prepare_requests.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ func PrepareRouteRequests(
9595
return reqs
9696
}
9797

98+
// removeDuplicateIndexParentRefs removes duplicate ParentRefs by Idx, keeping the first occurrence.
99+
// If an Idx is duplicated, the SectionName for the stored ParentRef is nil.
98100
func removeDuplicateIndexParentRefs(parentRefs []graph.ParentRef) []graph.ParentRef {
99101
idxCount := make(map[int]int)
100102
for _, ref := range parentRefs {
@@ -129,6 +131,10 @@ func prepareRouteStatus(
129131
transitionTime metav1.Time,
130132
srcGeneration int64,
131133
) v1.RouteStatus {
134+
// If a route did not specify a sectionName in its parentRefs section, it will attempt to attach to all available
135+
// listeners. In this case, parentRefs will be created and attached to the route for each attachable listener.
136+
// These parentRefs will all have the same Idx, and in order to not duplicate route statuses for the same Gateway,
137+
// we need to remove these duplicates. Additionally, we remove the sectionName.
132138
processedParentRefs := removeDuplicateIndexParentRefs(parentRefs)
133139

134140
parents := make([]v1.RouteParentStatus, 0, len(processedParentRefs))

0 commit comments

Comments
 (0)