diff --git a/source/gateway.go b/source/gateway.go index 6c07e5b8c..a2c273d9d 100644 --- a/source/gateway.go +++ b/source/gateway.go @@ -307,15 +307,8 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar for _, rps := range rt.RouteStatus().Parents { // Confirm the Parent is the standard Gateway kind. ref := rps.ParentRef - namespace := strVal((*string)(ref.Namespace), meta.Namespace) - // Ensure that the parent reference is for the current generation - if len(rps.Conditions) > 0 && rps.Conditions[0].ObservedGeneration != meta.Generation { - log.Debugf("Ignoring parent %s/%s of %s/%s as generation %d does not match current generation %d", namespace, ref.Name, meta.Namespace, meta.Name, rps.Conditions[0].ObservedGeneration, meta.Generation) - continue - } - // Ensure that the parent reference is in the routeParentRefs list if !gwRouteHasParentRef(routeParentRefs, ref, meta) { log.Debugf("Parent reference %s/%s not found in routeParentRefs for %s %s/%s", namespace, string(ref.Name), c.src.rtKind, meta.Namespace, meta.Name) @@ -341,10 +334,11 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar } // Confirm the Gateway has accepted the Route. - if !gwRouteIsAccepted(rps.Conditions) { - log.Debugf("Gateway %s/%s has not accepted %s %s/%s", namespace, ref.Name, c.src.rtKind, meta.Namespace, meta.Name) + if !gwRouteIsAccepted(rps.Conditions, meta) { + log.Debugf("Gateway %s/%s has not accepted the current generation %s %s/%s", namespace, ref.Name, c.src.rtKind, meta.Namespace, meta.Name) continue } + // Match the Route to all possible Listeners. match := false section := sectionVal(ref.SectionName, "") @@ -502,10 +496,10 @@ func gwRouteHasParentRef(routeParentRefs []v1.ParentReference, ref v1.ParentRefe return false } -func gwRouteIsAccepted(conds []metav1.Condition) bool { +func gwRouteIsAccepted(conds []metav1.Condition, meta *metav1.ObjectMeta) bool { for _, c := range conds { if v1.RouteConditionType(c.Type) == v1.RouteConditionAccepted { - return c.Status == metav1.ConditionTrue + return c.Status == metav1.ConditionTrue && c.ObservedGeneration == meta.Generation } } return false diff --git a/source/gateway_httproute_test.go b/source/gateway_httproute_test.go index 2d068ae6a..abeb06b1b 100644 --- a/source/gateway_httproute_test.go +++ b/source/gateway_httproute_test.go @@ -246,7 +246,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { newTestEndpoint("test.example.internal", "A", "1.2.3.4"), }, logExpectations: []string{ - "level=debug msg=\"Ignoring parent gateway-namespace/gateway-name of route-namespace/old-test as generation 4 does not match current generation 5\"", + "level=debug msg=\"Gateway gateway-namespace/gateway-name has not accepted the current generation HTTPRoute route-namespace/old-test\"", }, }, {