diff --git a/internal/gatewayapi/backendtlspolicy.go b/internal/gatewayapi/backendtlspolicy.go index 8c022d34522..e147589577a 100644 --- a/internal/gatewayapi/backendtlspolicy.go +++ b/internal/gatewayapi/backendtlspolicy.go @@ -162,41 +162,3 @@ func getBackendTLSBundle(policies []*gwapiv1a2.BackendTLSPolicy, configmaps []*c return tlsBundle, nil } - -func (t *Translator) ProcessBackendTLSPoliciesAncestorRef(backendTLSPolicies []*gwapiv1a2.BackendTLSPolicy, gateways []*GatewayContext) []*gwapiv1a2.BackendTLSPolicy { - - var res []*gwapiv1a2.BackendTLSPolicy - - for _, btlsPolicy := range backendTLSPolicies { - - policy := btlsPolicy.DeepCopy() - res = append(res, policy) - - if policy.Status.Ancestors != nil { - for k, status := range policy.Status.Ancestors { - if status.AncestorRef.Kind != nil && *status.AncestorRef.Kind != KindGateway { - continue - } - exist := false - for _, gwContext := range gateways { - gw := gwContext.Gateway - if gw.Name == string(status.AncestorRef.Name) && gw.Namespace == NamespaceDerefOrAlpha(status.AncestorRef.Namespace, "default") { - for _, lis := range gw.Spec.Listeners { - if lis.Name == ptr.Deref(status.AncestorRef.SectionName, "") { - exist = true - } - } - } - } - - if !exist { - policy.Status.Ancestors = append(policy.Status.Ancestors[:k], policy.Status.Ancestors[k+1:]...) - } - } - } else { - policy.Status.Ancestors = []gwapiv1a2.PolicyAncestorStatus{} - } - } - - return res -} diff --git a/internal/gatewayapi/translator.go b/internal/gatewayapi/translator.go index 51b7b6fb7dd..83a819fbd23 100644 --- a/internal/gatewayapi/translator.go +++ b/internal/gatewayapi/translator.go @@ -207,15 +207,12 @@ func (t *Translator) Translate(resources *Resources) *TranslateResult { securityPolicies := t.ProcessSecurityPolicies( resources.SecurityPolicies, gateways, routes, resources, xdsIR) - backendTLSPolicies := t.ProcessBackendTLSPoliciesAncestorRef( - resources.BackendTLSPolicies, gateways) - // Sort xdsIR based on the Gateway API spec sortXdsIRMap(xdsIR) return newTranslateResult(gateways, httpRoutes, grpcRoutes, tlsRoutes, tcpRoutes, udpRoutes, clientTrafficPolicies, backendTrafficPolicies, - securityPolicies, backendTLSPolicies, xdsIR, infraIR) + securityPolicies, resources.BackendTLSPolicies, xdsIR, infraIR) } diff --git a/internal/provider/kubernetes/controller.go b/internal/provider/kubernetes/controller.go index 1b499856ae8..de40a862f18 100644 --- a/internal/provider/kubernetes/controller.go +++ b/internal/provider/kubernetes/controller.go @@ -863,9 +863,8 @@ func (r *gatewayAPIReconciler) processBackendTLSPolicies( for _, policy := range backendTLSPolicies.Items { policy := policy - // Discard Status to reduce memory consumption in watchable - // It will be recomputed by the gateway-api layer - policy.Status = gwapiv1a2.PolicyStatus{} // todo ? + // The status of BackendTLSPolicies can't be discarded because the status + // can be modified by multiple controllers. resourceTree.BackendTLSPolicies = append(resourceTree.BackendTLSPolicies, &policy) }