Change:
} } <ins> func TestComposeDNSSearch(t *testing.T) { testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */) kubelet := testKubelet.kubelet recorder := record.NewFakeRecorder(20) kubelet.recorder = recorder pod := podWithUidNameNs("", "test_pod", "testNS") kubelet.clusterDomain = "TEST" testCases := []struct { dnsNames     []string hostNames    []string resultSearch []string events       []string }{ { []string{"testNS.svc.TEST", "svc.TEST", "TEST"}, []string{}, []string{"testNS.svc.TEST", "svc.TEST", "TEST"}, []string{}, }, { []string{"testNS.svc.TEST", "svc.TEST", "TEST"}, []string{"AAA", "svc.TEST", "BBB", "TEST"}, []string{"testNS.svc.TEST", "svc.TEST", "TEST", "AAA", "BBB"}, []string{ "Found and omitted duplicated dns domain in host search line: 'svc.TEST' during merging with cluster dns domains", "Found and omitted duplicated dns domain in host search line: 'TEST' during merging with cluster dns domains", }, }, { []string{"testNS.svc.TEST", "svc.TEST", "TEST"}, []string{"AAA", strings.Repeat("B", 256), "BBB"}, []string{"testNS.svc.TEST", "svc.TEST", "TEST", "AAA"}, []string{"Search Line limits were exceeded, some dns names have been omitted, the applied search line is: testNS.svc.TEST svc.TEST TEST AAA"}, }, { []string{"testNS.svc.TEST", "svc.TEST", "TEST"}, []string{"AAA", "TEST", "BBB", "TEST", "CCC", "DDD"}, []string{"testNS.svc.TEST", "svc.TEST", "TEST", "AAA", "BBB", "CCC"}, []string{ "Found and omitted duplicated dns domain in host search line: 'TEST' during merging with cluster dns domains", "Found and omitted duplicated dns domain in host search line: 'TEST' during merging with cluster dns domains", "Search Line limits were exceeded, some dns names have been omitted, the applied search line is: testNS.svc.TEST svc.TEST TEST AAA BBB CCC", }, }, } fetchEvent := func(recorder *record.FakeRecorder) string { select { case event := <-recorder.Events: return event default: return "No more events!" } } for i, tc := range testCases { dnsSearch := kubelet.formDNSSearch(tc.hostNames, pod) if !reflect.DeepEqual(dnsSearch, tc.resultSearch) { t.Errorf("[%d] expected search line %#v, got %#v", i, tc.resultSearch, dnsSearch) } for _, expectedEvent := range tc.events { expected := fmt.Sprintf("%s %s %s", v1.EventTypeWarning, "DNSSearchForming", expectedEvent) event := fetchEvent(recorder) if event != expected { t.Errorf("[%d] expected event '%s', got '%s", i, expected, event) } } } } </ins> func TestCleanupBandwidthLimits(t *testing.T) { testPod := func(name, ingress string) *v1.Pod { pod := podWithUidNameNs("", name, "")

Discussion:
Kubernetes version v1.3.0 Kubelet concatenates host and cluster domain entries for my pod, resulting in an invalid config (too many entries with duplicates). The max is only 6 search domains. Any more and DNS resolution breaks when trying to leverage search domains. The example below has only cluster DNS entries, but illustrates the issue: Host search nameserver 10.233.0.2 nameserver 10.90.0.1 options timeout:2 options attempts:2 Container kubectl run -i --tty busybox --image=busybox -- sh (skip waiting text) / # cat search nameserver 10.233.0.2 options attempts:2 options ndots:5 I should be enable cluster DNS config in my host DNS settings and still have functional pod DNS. Kubelet should be intelligent enough to filter out duplicate search domain entries (or drop search domains beyond the 6th entry)
I think some sane checks needs to be too. libc limits search field to 6 records and 255(?) characters. This limitation should be checked before creation.
Hey guys, I'm working on it.
Dup of