Unverified Commit 9c5be7aa authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #74686 from zhouhaibing089/add-trailing-period

validation: allow trailing period in dns search
parents 6a2936dc 68beadef
...@@ -2704,6 +2704,10 @@ func validatePodDNSConfig(dnsConfig *core.PodDNSConfig, dnsPolicy *core.DNSPolic ...@@ -2704,6 +2704,10 @@ func validatePodDNSConfig(dnsConfig *core.PodDNSConfig, dnsPolicy *core.DNSPolic
allErrs = append(allErrs, field.Invalid(fldPath.Child("searches"), dnsConfig.Searches, "must not have more than 256 characters (including spaces) in the search list")) allErrs = append(allErrs, field.Invalid(fldPath.Child("searches"), dnsConfig.Searches, "must not have more than 256 characters (including spaces) in the search list"))
} }
for i, search := range dnsConfig.Searches { for i, search := range dnsConfig.Searches {
// it is fine to have a trailing dot
if strings.HasSuffix(search, ".") {
search = search[0 : len(search)-1]
}
allErrs = append(allErrs, ValidateDNS1123Subdomain(search, fldPath.Child("searches").Index(i))...) allErrs = append(allErrs, ValidateDNS1123Subdomain(search, fldPath.Child("searches").Index(i))...)
} }
// Validate options. // Validate options.
......
...@@ -5878,10 +5878,17 @@ func TestValidatePodDNSConfig(t *testing.T) { ...@@ -5878,10 +5878,17 @@ func TestValidatePodDNSConfig(t *testing.T) {
expectedError: false, expectedError: false,
}, },
{ {
desc: "valid: 1 search path with trailing period",
dnsConfig: &core.PodDNSConfig{
Searches: []string{"custom."},
},
expectedError: false,
},
{
desc: "valid: 3 nameservers and 6 search paths", desc: "valid: 3 nameservers and 6 search paths",
dnsConfig: &core.PodDNSConfig{ dnsConfig: &core.PodDNSConfig{
Nameservers: []string{"127.0.0.1", "10.0.0.10", "8.8.8.8"}, Nameservers: []string{"127.0.0.1", "10.0.0.10", "8.8.8.8"},
Searches: []string{"custom", "mydomain.com", "local", "cluster.local", "svc.cluster.local", "default.svc.cluster.local"}, Searches: []string{"custom", "mydomain.com", "local", "cluster.local", "svc.cluster.local", "default.svc.cluster.local."},
}, },
expectedError: false, expectedError: false,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment