Skip to content

Commit ff13742

Browse files
authored
fix: prevent skeleton route status entries for unmanaged GatewayClasses (#7536)
* fix: prevent skeleton route status entries for unmanaged GatewayClasses When processing policies (EnvoyExtensionPolicy, SecurityPolicy), the translator was calling GetRouteParentContext for ALL parentRefs in a route, even those referencing gateways with different GatewayClasses not managed by this translator. GetRouteParentContext creates a skeleton RouteParentStatus entry with just the controllerName when called on a parentRef that hasn't been processed yet. Since all GatewayClass instances share the same controller name, these skeleton entries persisted in status without conditions. The fix checks if a parentRef context already exists before attempting to apply policy configuration to it. If the context doesn't exist, it means this parentRef wasn't processed by this translator and should be skipped. Signed-off-by: Raj Singh <[email protected]> * fix: also prevent skeleton entries in BackendTrafficPolicy processing The same issue exists in BackendTrafficPolicy route processing - calling GetRouteParentContext for all parentRefs creates skeleton status entries. Apply the same fix: check if parentRef context exists before adding to list. Signed-off-by: Raj Singh <[email protected]> --------- Signed-off-by: Raj Singh <[email protected]>
1 parent 0d0c230 commit ff13742

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

internal/gatewayapi/backendtrafficpolicy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ func (t *Translator) processBackendTrafficPolicyForRoute(
282282
ancestorRef := getAncestorRefForPolicy(mapKey.NamespacedName, p.SectionName)
283283
ancestorRefs = append(ancestorRefs, &ancestorRef)
284284

285-
parentRefCtxs = append(parentRefCtxs, GetRouteParentContext(targetedRoute, p, t.GatewayControllerName))
285+
// Only process parentRefs that were handled by this translator
286+
// (skip those referencing Gateways with different GatewayClasses)
287+
if parentRefCtx := targetedRoute.GetRouteParentContext(p); parentRefCtx != nil {
288+
parentRefCtxs = append(parentRefCtxs, parentRefCtx)
289+
}
286290
}
287291
}
288292

internal/gatewayapi/envoyextensionpolicy.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,12 @@ func (t *Translator) translateEnvoyExtensionPolicyForRoute(
475475
parentRefs := GetParentReferences(route)
476476
routesWithDirectResponse := sets.New[string]()
477477
for _, p := range parentRefs {
478-
parentRefCtx := GetRouteParentContext(route, p, t.GatewayControllerName)
478+
// Skip if this parentRef was not processed by this translator
479+
// (e.g., references a Gateway with a different GatewayClass)
480+
parentRefCtx := route.GetRouteParentContext(p)
481+
if parentRefCtx == nil {
482+
continue
483+
}
479484
gtwCtx := parentRefCtx.GetGateway()
480485
if gtwCtx == nil {
481486
continue

internal/gatewayapi/securitypolicy.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,12 @@ func (t *Translator) translateSecurityPolicyForRoute(
647647
parentRefs := GetParentReferences(route)
648648
routesWithDirectResponse := sets.New[string]()
649649
for _, p := range parentRefs {
650-
parentRefCtx := GetRouteParentContext(route, p, t.GatewayControllerName)
650+
// Skip if this parentRef was not processed by this translator
651+
// (e.g., references a Gateway with a different GatewayClass)
652+
parentRefCtx := route.GetRouteParentContext(p)
653+
if parentRefCtx == nil {
654+
continue
655+
}
651656
gtwCtx := parentRefCtx.GetGateway()
652657
if gtwCtx == nil {
653658
continue

0 commit comments

Comments
 (0)