From 6aaaab92555ee876a6443fa21005d2e6348ee1c2 Mon Sep 17 00:00:00 2001 From: Lior Okman Date: Sun, 4 Aug 2024 11:34:48 +0300 Subject: [PATCH] Translate DNS settings correctly. Signed-off-by: Lior Okman --- internal/gatewayapi/backendtrafficpolicy.go | 4 ++-- internal/gatewayapi/clustersettings.go | 10 ++++++---- ...npolicy-with-extproc-with-traffic-features.out.yaml | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/gatewayapi/backendtrafficpolicy.go b/internal/gatewayapi/backendtrafficpolicy.go index 7e43179b820..bf083b95fcf 100644 --- a/internal/gatewayapi/backendtrafficpolicy.go +++ b/internal/gatewayapi/backendtrafficpolicy.go @@ -341,7 +341,7 @@ func (t *Translator) translateBackendTrafficPolicyForRoute(policy *egv1a1.Backen errs = errors.Join(errs, err) } } - ds = translateDNS(policy.Spec.DNS) + ds = translateDNS(policy.Spec.ClusterSettings) // Early return if got any errors if errs != nil { @@ -471,7 +471,7 @@ func (t *Translator) translateBackendTrafficPolicyForGateway(policy *egv1a1.Back } } - ds = translateDNS(policy.Spec.DNS) + ds = translateDNS(policy.Spec.ClusterSettings) // Early return if got any errors if errs != nil { diff --git a/internal/gatewayapi/clustersettings.go b/internal/gatewayapi/clustersettings.go index 5319d13d5b1..fe4d06aa73b 100644 --- a/internal/gatewayapi/clustersettings.go +++ b/internal/gatewayapi/clustersettings.go @@ -62,6 +62,8 @@ func translateTrafficFeatures(policy *egv1a1.ClusterSettings) (*ir.TrafficFeatur ret.HealthCheck = buildHealthCheck(*policy) + ret.DNS = translateDNS(*policy) + // If nothing was set in any of the above calls, return nil instead of an empty // container var empty ir.TrafficFeatures @@ -481,12 +483,12 @@ func translateActiveHealthCheckPayload(p *egv1a1.ActiveHealthCheckPayload) *ir.H return irPayload } -func translateDNS(policy *egv1a1.DNS) *ir.DNS { - if policy == nil { +func translateDNS(policy egv1a1.ClusterSettings) *ir.DNS { + if policy.DNS == nil { return nil } return &ir.DNS{ - RespectDNSTTL: policy.RespectDNSTTL, - DNSRefreshRate: policy.DNSRefreshRate, + RespectDNSTTL: policy.DNS.RespectDNSTTL, + DNSRefreshRate: policy.DNS.DNSRefreshRate, } } diff --git a/internal/gatewayapi/testdata/envoyextensionpolicy-with-extproc-with-traffic-features.out.yaml b/internal/gatewayapi/testdata/envoyextensionpolicy-with-extproc-with-traffic-features.out.yaml index 85c14e8d66b..0290dd1db09 100644 --- a/internal/gatewayapi/testdata/envoyextensionpolicy-with-extproc-with-traffic-features.out.yaml +++ b/internal/gatewayapi/testdata/envoyextensionpolicy-with-extproc-with-traffic-features.out.yaml @@ -371,6 +371,8 @@ xdsIR: bufferLimit: 20971520 circuitBreaker: maxConnections: 2048 + dns: + respectDnsTtl: true healthCheck: passive: consecutiveGatewayErrors: 4