Preserve pod DNS options when translating ClusterFirst DNS - #4105
Open
Kunalbehbud wants to merge 1 commit into
Open
Kunalbehbud wants to merge 1 commit into
Kunalbehbud wants to merge 1 commit into
Conversation
translateDNSClusterFirstConfig merged the pod's nameservers and searches back into the generated DNS config but dropped its options, so a pod setting dnsConfig.options silently lost them. Merge the options too. An option set on the pod wins over the injected default of the same name, so an explicit ndots replaces the injected ndots=5 instead of being discarded. Fixes loft-sh#1120
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix
What does this pull request do? Which issues does it resolve? (use
resolves #<issue_number>if possible)resolves #1120
When a pod uses
ClusterFirstDNS,translateDNSClusterFirstConfigbuilds a DNS config (nameserver + search domains + an injectedndots=5) and then merges the pod's own config back in — but only itsNameserversandSearches:Optionswas never merged, so anything a pod set indnsConfig.options(e.g.single-request-reopen, or a customndots) was silently dropped — exactly what the issue reports.This merges the options too, via a small
mergeDNSOptionshelper. An option set on the pod takes precedence over the injected default with the same name, so an explicitndots: "2"replaces the injectedndots=5rather than colliding with it; options the pod sets that aren't in the defaults are simply appended.Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster dropped a pod's
dnsConfig.optionswhen translatingClusterFirstDNS.What else do we need to know?
translateDNSClusterFirstConfigis a pure function overcorev1.Pod, so this is covered by a table-driven unit test (TestTranslateDNSClusterFirstConfigOptions) with no cluster required: default kept when the pod sets nothing, pod options preserved alongside the default, and podndotsoverriding the injected one. The test fails onmainand passes with this change.Note
Low Risk
Small, localized pod DNS translation fix with table-driven unit tests and no auth or data-path changes.
Overview
Fixes a bug where virtual pods with
ClusterFirstDNS lostdnsConfig.optionson the host pod.translateDNSClusterFirstConfigalready merged nameservers and search domains from the pod spec but ignored options, so settings likesingle-request-reopenor a customndotsnever reached the physical pod.The merge path now calls
mergeDNSOptions, which keeps injected defaults (includingndots=5) unless the pod defines the same option name—in which case the pod value wins. Other pod-only options are kept alongside the defaults.TestTranslateDNSClusterFirstConfigOptionscovers no existing config, extra pod options, and podndotsoverriding the default.Reviewed by Cursor Bugbot for commit cc3b0ed. Bugbot is set up for automated code reviews on this repo. Configure here.