Skip to content

feat: expose maxHosts for DynamicResolver DNS cache - #9740

Open
vishals-3 wants to merge 1 commit into
envoyproxy:mainfrom
vishals-3:dns-max-hosts
Open

feat: expose maxHosts for DynamicResolver DNS cache#9740
vishals-3 wants to merge 1 commit into
envoyproxy:mainfrom
vishals-3:dns-max-hosts

Conversation

@vishals-3

Copy link
Copy Markdown

Fixes #9382

What this does

Envoy's dynamic_forward_proxy DnsCacheConfig supports a max_hosts field that bounds how many hosts the DNS cache holds. Envoy Gateway did not expose it, so it was pinned to Envoy's default of 1024. This adds a first-class maxHosts field to the DNS configuration.

Design

The field is added to the shared DNS type, so it is configurable everywhere existing DNS settings live (BackendTrafficPolicy, EnvoyExtensionPolicy, EnvoyProxy, SecurityPolicy) — consistent with how dnsRefreshRate and lookupFamily are already surfaced. It flows through the standard pipeline:

  • APIapi/v1alpha1/dns_types.go: MaxHosts *uint32 (+kubebuilder:validation:Minimum=1)
  • IRinternal/ir/xds.go: MaxHosts *uint32 on the internal DNS struct
  • API → IRinternal/gatewayapi/clustersettings.go (translateDNS)
  • IR → xDSinternal/xds/translator/cluster.go (buildDFPDNSCacheConfig), which feeds both the cluster and SNI dynamic-forward-proxy paths

When unset, Envoy's default is preserved.

The issue floated Backend / DynamicResolver / EnvoyProxy as candidate homes for the field; putting it on the shared DNS type covers those via the existing ClusterSettings.dns surface. Happy to move it if maintainers prefer a narrower placement.

Testing

Generated code (deepcopy, CRDs, API reference docs) was regenerated with the repo's own tooling (controller-gen, crd-ref-docs).

  • New xDS translator golden case http-route-dynamic-resolver-dns-max-hosts asserting maxHosts in the rendered Envoy dnsCacheConfig
  • Extended the gatewayapi backendtrafficpolicy-with-dns-settings fixture to exercise the API→IR conversion
  • New TestBuildDFPDNSCacheConfig unit test covering nil / unset / set
go test ./internal/xds/translator/ ./internal/gatewayapi/ ./internal/ir/ ./api/...
go vet ./internal/xds/translator/ ./internal/gatewayapi/ ./internal/ir/ ./api/...

This PR was authored with the assistance of Claude, an AI assistant.

🤖 Generated with Claude Code

Envoy's dynamic_forward_proxy DnsCacheConfig supports a max_hosts field
that bounds the number of hosts held in the DNS cache, but Envoy Gateway
did not surface it through any API, so it was stuck at Envoy's default of
1024. This adds a first-class `maxHosts` field to the DNS config.

The field is added to the shared DNS type so it is configurable everywhere
existing DNS settings live (BackendTrafficPolicy, EnvoyExtensionPolicy,
EnvoyProxy, SecurityPolicy), consistent with how dnsRefreshRate and
lookupFamily are already exposed. It flows API -> IR (translateDNS) ->
xDS (buildDFPDNSCacheConfig), which feeds both the cluster and SNI
dynamic-forward-proxy paths. When unset, Envoy's default is preserved.

Fixes envoyproxy#9382

Test Plan:

Regenerated deepcopy, CRDs, and API reference docs via controller-gen and
crd-ref-docs (the repo's own tooling).

```
go test ./internal/xds/translator/ ./internal/gatewayapi/ ./internal/ir/ ./api/...
go vet ./internal/xds/translator/ ./internal/gatewayapi/ ./internal/ir/ ./api/...
```

Added a translator golden case (http-route-dynamic-resolver-dns-max-hosts)
asserting `maxHosts` in the rendered Envoy dnsCacheConfig, extended the
gatewayapi backendtrafficpolicy-with-dns-settings fixture to exercise the
API->IR conversion, and added TestBuildDFPDNSCacheConfig covering the
nil/unset/set cases.

This change was authored with the assistance of Claude, an AI assistant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vishals-3
vishals-3 requested a review from a team as a code owner August 13, 2026 05:18
@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit aee307f
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a7d53acf2c8fd0008b644e3
😎 Deploy Preview https://deploy-preview-9740--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aee307f811

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- IPv6Preferred
- IPv4AndIPv6
type: string
maxHosts:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update Helm golden outputs for maxHosts

This generated CRD schema now renders maxHosts, but none of the test/helm/*.out.yaml golden manifests were updated (I checked rg -n maxHosts test/helm). make gen-check runs helm-template and then fails on any worktree diff (tools/make/lint.mk:81-85, with gateway-crds-helm rendering from tools/make/helm.mk:83-90), so this change will leave CI/presubmit dirty until the Helm golden outputs are regenerated.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose maxHosts for DynamicResolver DNS cache

1 participant