Skip to content

Commit 84b8940

Browse files
jukiezirain
authored andcommitted
chore: cleanups from envoyproxy#6597 (envoyproxy#6647)
Cleanup Signed-off-by: jukie <10012479+Jukie@users.noreply.github.com>
1 parent c988ec5 commit 84b8940

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

internal/gatewayapi/globalresources.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ func (t *Translator) ProcessGlobalResources(resources *resource.Resources, xdsIR
3232
xdsIRs[irKey].GlobalResources = &ir.GlobalResources{}
3333
}
3434
xdsIRs[irKey].GlobalResources.ProxyServiceCluster = rDest
35+
36+
// For merged gateways we only need to process once
37+
if t.MergeGateways {
38+
break
39+
}
3540
}
3641

3742
// Get the envoy client TLS secret. It is used for envoy to establish a TLS connection with control plane components,

internal/provider/kubernetes/predicates.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func (r *gatewayAPIReconciler) validateEndpointSliceForReconcile(obj client.Obje
614614
}
615615
}
616616

617-
if r.isProxyServiceCluster(&nsName) {
617+
if r.isProxyServiceCluster(ep.GetLabels()) {
618618
return true
619619
}
620620
return false
@@ -940,23 +940,13 @@ func (r *gatewayAPIReconciler) isRouteReferencingHTTPRouteFilter(nsName *types.N
940940
return len(httpRouteList.Items) != 0
941941
}
942942

943-
func (r *gatewayAPIReconciler) isProxyServiceCluster(nn *types.NamespacedName) bool {
944-
ctx := context.Background()
945-
svc := &corev1.Service{}
946-
if err := r.client.Get(ctx, *nn, svc); err != nil {
947-
r.log.Error(err, "unable to find associated proxy ServiceCluster")
948-
return false
949-
}
950-
951-
svcLabels := svc.GetLabels()
952-
953-
// Check if service belongs to a Gateway
954-
if gtw := r.findOwningGateway(ctx, svcLabels); gtw != nil {
943+
// isProxyServiceCluster returns true if the provided labels reference an owning Gateway or GatewayClass
944+
func (r *gatewayAPIReconciler) isProxyServiceCluster(labels map[string]string) bool {
945+
if gtw := r.findOwningGateway(context.Background(), labels); gtw != nil {
955946
return true
956947
}
957948

958-
// Check if service belongs to a GatewayClass
959-
gcName, ok := svcLabels[gatewayapi.OwningGatewayClassLabel]
949+
gcName, ok := labels[gatewayapi.OwningGatewayClassLabel]
960950
if ok && r.mergeGateways.Has(gcName) {
961951
return true
962952
}

0 commit comments

Comments
 (0)