@@ -280,13 +280,13 @@ func (r *gatewayAPIReconciler) isOIDCHMACSecret(nsName *types.NamespacedName) bo
280280 return * nsName == oidcHMACSecret
281281}
282282
283- // isServiceOwnedByGateway returns true if the Service belongs to a Gateway.
284- func (r * gatewayAPIReconciler ) isServiceOwnedByGateway (svc * corev1.Service ) bool {
283+ // validateServiceOwnedByGateway returns true if the Service belongs to a Gateway.
284+ func (r * gatewayAPIReconciler ) validateServiceOwnedByGateway (svc * corev1.Service ) bool {
285285 ctx := context .Background ()
286286 labels := svc .GetLabels ()
287287
288288 // Check if the Service belongs to a Gateway, if so, update the Gateway status.
289- gtw := r .findOwningGateway (context . Background () , labels )
289+ gtw := r .findOwningGateway (ctx , labels )
290290 if gtw != nil {
291291 r .updateGatewayStatus (gtw )
292292 return true
@@ -306,32 +306,29 @@ func (r *gatewayAPIReconciler) isServiceOwnedByGateway(svc *corev1.Service) bool
306306}
307307
308308// validateServiceUpdateForReconcile checks whether a Service update should trigger a reconcile.
309- // Returns false when the backend does not have endpoint routing and the service of type clusterIP
309+ // Returns false when the backend does not have endpoint routing and the service of type clusterIP
310310// does not have a new IP address.
311311func (r * gatewayAPIReconciler ) validateServiceUpdateForReconcile (oldObj client.Object , newObj client.Object ) bool {
312312 oldSvc , ok := oldObj .(* corev1.Service )
313313 if ! ok {
314314 r .log .Info ("unexpected object type, bypassing reconciliation" , "object" , oldObj )
315- return true
315+ return false
316316 }
317317 newSvc , ok := newObj .(* corev1.Service )
318318 if ! ok {
319319 r .log .Info ("unexpected object type, bypassing reconciliation" , "object" , newObj )
320- return true
321- }
322-
323- if r .isServiceOwnedByGateway (newSvc ) {
324- return true
320+ return false
325321 }
326322
327- if ( newSvc . Spec . Type != corev1 . ServiceTypeClusterIP ) || ( oldSvc . Spec . Type != corev1 . ServiceTypeClusterIP ) || ( newSvc . Spec . ClusterIP != oldSvc . Spec . ClusterIP ) {
328- return true
323+ if r . validateServiceOwnedByGateway ( newSvc ) {
324+ return false
329325 }
330326
331327 nsName := utils .NamespacedName (newSvc )
332328 if ! r .hasRouteWithEndpointRouting (& nsName ) {
333- r .log .Info ("validateServiceUpdateForReconcile -- Service is not referenced by backend with endpoint routing" , "service" , nsName )
334- return false
329+ if (newSvc .Spec .Type != corev1 .ServiceTypeClusterIP ) || (oldSvc .Spec .Type != corev1 .ServiceTypeClusterIP ) || (newSvc .Spec .ClusterIP != oldSvc .Spec .ClusterIP ) {
330+ return false
331+ }
335332 }
336333
337334 return true
@@ -347,13 +344,12 @@ func (r *gatewayAPIReconciler) validateServiceForReconcile(obj client.Object) bo
347344 return false
348345 }
349346
350- if r .isServiceOwnedByGateway (svc ) {
347+ if r .validateServiceOwnedByGateway (svc ) {
351348 return false
352349 }
353350
354351 nsName := utils .NamespacedName (svc )
355352 if r .isRouteReferencingBackend (& nsName ) {
356- r .log .Info ("validateServiceForReconcile -- Service is referenced by a Route" , "service" , nsName )
357353 return true
358354 }
359355
@@ -477,9 +473,7 @@ func (r *gatewayAPIReconciler) isRouteReferencingBackend(nsName *types.Namespace
477473 return false
478474 }
479475 if len (tlsRouteList .Items ) > 0 {
480- // we don't know the old value of the service clusterIP here, so we can't avoid reconciling on service change.
481476 return true
482-
483477 }
484478 }
485479
0 commit comments