Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove ProcessBackendTLSPoliciesAncestorRef #2845

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions internal/gatewayapi/backendtlspolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 1 addition & 4 deletions internal/gatewayapi/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

Expand Down
5 changes: 2 additions & 3 deletions internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,8 @@

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
zhaohuabing marked this conversation as resolved.
Show resolved Hide resolved
// can be modified by multiple controllers.

Check warning on line 877 in internal/provider/kubernetes/controller.go

View check run for this annotation

Codecov / codecov/patch

internal/provider/kubernetes/controller.go#L876-L877

Added lines #L876 - L877 were not covered by tests
resourceTree.BackendTLSPolicies = append(resourceTree.BackendTLSPolicies, &policy)
}

Expand Down