Skip to content

Commit

Permalink
feat: sectionName check on attachedRoutes
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Lavacca <[email protected]>
  • Loading branch information
mlavacca committed Jun 18, 2024
1 parent b61c8b9 commit 6a5236c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions controller/gateway/controller_reconciler_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func countAttachedRoutesForGatewayListener(ctx context.Context, g *gwtypes.Gatew
client.ObjectKeyFromObject(g), err,
)
}
count += int32(len(httpRoutes))
count += countAttachedHTTPRoutes(listener.Name, httpRoutes)
default:
return 0, fmt.Errorf("unsupported route kind: %T", k)
}
Expand All @@ -723,13 +723,26 @@ func countAttachedRoutesForGatewayListener(ctx context.Context, g *gwtypes.Gatew
)
}

count += int32(len(httpRoutes))
count += countAttachedHTTPRoutes(listener.Name, httpRoutes)
}
}

return count, nil
}

func countAttachedHTTPRoutes(listenerName gatewayv1.SectionName, httpRoutes []gatewayv1.HTTPRoute) int32 {
var count int32
for _, httpRoute := range httpRoutes {
if lo.ContainsBy(httpRoute.Spec.ParentRefs, func(item gatewayv1.ParentReference) bool {
return item.SectionName == nil || *item.SectionName == listenerName
}) {
count++
}
}

return count
}

// setConflicted sets the gateway Conflicted condition according to the Gateway API specification.
func (g *gatewayConditionsAndListenersAwareT) setConflicted() {
for i, l := range g.Spec.Listeners {
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ var (
features.SupportHTTPRouteHostRewrite,
)

traditionalCompatibleRouterSupportedFeatures = commonSupportedFeatures.Insert(
traditionalCompatibleRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// add here the traditional compatible router specific features
)

expressionsRouterSupportedFeatures = commonSupportedFeatures.Insert(
expressionsRouterSupportedFeatures = commonSupportedFeatures.Clone().Insert(
// extended
features.SupportHTTPRouteMethodMatching,
features.SupportHTTPRouteQueryParamMatching,
Expand Down

0 comments on commit 6a5236c

Please sign in to comment.