mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
chore: move into pre-existing conditions check
This commit is contained in:
parent
11ca783976
commit
0dcd6c922c
@ -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
|
||||
|
@ -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\"",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user