revert: fix on gateway-api that ensure to use only latest generation with HTTPRoutes (#5490)

This commit is contained in:
Michel Loiseleur 2025-06-04 09:56:38 +02:00 committed by GitHub
parent e5f533fed5
commit 7fb0ed0857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 44 deletions

View File

@ -336,7 +336,7 @@ func (c *gatewayRouteResolver) resolve(rt gatewayRoute) (map[string]endpoint.Tar
} }
// Confirm the Gateway has accepted the Route. // Confirm the Gateway has accepted the Route.
if !gwRouteIsAccepted(rps.Conditions, meta) { if !gwRouteIsAccepted(rps.Conditions) {
log.Debugf("Gateway %s/%s has not accepted the current generation %s %s/%s", namespace, ref.Name, c.src.rtKind, meta.Namespace, meta.Name) 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 continue
} }
@ -498,10 +498,10 @@ func gwRouteHasParentRef(routeParentRefs []v1.ParentReference, ref v1.ParentRefe
return false return false
} }
func gwRouteIsAccepted(conds []metav1.Condition, meta *metav1.ObjectMeta) bool { func gwRouteIsAccepted(conds []metav1.Condition) bool {
for _, c := range conds { for _, c := range conds {
if v1.RouteConditionType(c.Type) == v1.RouteConditionAccepted { if v1.RouteConditionType(c.Type) == v1.RouteConditionAccepted {
return c.Status == metav1.ConditionTrue && c.ObservedGeneration == meta.Generation return c.Status == metav1.ConditionTrue
} }
} }
return false return false

View File

@ -224,46 +224,6 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
"Gateway gateway-namespace/not-gateway-name does not match gateway-name route-namespace/test", "Gateway gateway-namespace/not-gateway-name does not match gateway-name route-namespace/test",
}, },
}, },
{
title: "GatewayNameOldGeneration",
config: Config{
GatewayName: "gateway-name",
},
namespaces: namespaces("gateway-namespace", "route-namespace"),
gateways: []*v1beta1.Gateway{
{
ObjectMeta: omWithGeneration(objectMeta("gateway-namespace", "gateway-name"), 2),
Spec: v1.GatewaySpec{
Listeners: []v1.Listener{{
Protocol: v1.HTTPProtocolType,
AllowedRoutes: allowAllNamespaces,
}},
},
Status: gatewayStatus("1.2.3.4"),
},
},
routes: []*v1beta1.HTTPRoute{{
ObjectMeta: omWithGeneration(objectMeta("route-namespace", "old-test"), 5),
Spec: v1.HTTPRouteSpec{
Hostnames: hostnames("test.example.internal"),
CommonRouteSpec: v1.CommonRouteSpec{
ParentRefs: []v1.ParentReference{
gwParentRef("gateway-namespace", "gateway-name"),
},
},
},
Status: rsWithGeneration(httpRouteStatus( // The route was previously attached in a different generation
gwParentRef("gateway-namespace", "gateway-name"),
gwParentRef("gateway-namespace", "gateway-name"),
), 5, 4),
}},
endpoints: []*endpoint.Endpoint{
newTestEndpoint("test.example.internal", "A", "1.2.3.4"),
},
logExpectations: []string{
"Gateway gateway-namespace/gateway-name has not accepted the current generation HTTPRoute route-namespace/old-test",
},
},
{ {
title: "GatewayNameNoneAccepted", title: "GatewayNameNoneAccepted",
config: Config{ config: Config{
@ -1582,7 +1542,6 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.title, func(t *testing.T) { t.Run(tt.title, func(t *testing.T) {
if len(tt.logExpectations) == 0 { if len(tt.logExpectations) == 0 {
t.Parallel() t.Parallel()