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

remove trailing dots from the parsed searches from host resolv.conf #83069

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/kubelet/network/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
}
}
if fields[0] == "search" {
searches = fields[1:]
// Normalise search fields so the same domain with and without trailing dot will only count once, to avoid hitting search validation limits.
searches = []string{}
for _, s := range fields[1:] {
searches = append(searches, strings.TrimSuffix(s, "."))
}
}
if fields[0] == "options" {
options = fields[1:]
Expand Down
1 change: 1 addition & 0 deletions pkg/kubelet/network/dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestParseResolvConf(t *testing.T) {
{"search ", []string{}, []string{}, []string{}, false}, // search empty
{"search foo", []string{}, []string{"foo"}, []string{}, false},
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}, []string{}, false},
{"search foo\nsearch bar", []string{}, []string{"bar"}, []string{}, false},
{"nameserver 1.2.3.4\nsearch foo bar", []string{"1.2.3.4"}, []string{"foo", "bar"}, []string{}, false},
Expand Down