mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	This reverts commit f4f0d55dce.
Signed-off-by: Adrian Moisey <adrian@changeover.za.net>
			
			
This commit is contained in:
		| @@ -44,13 +44,8 @@ func (k *Kubernetes) serviceRecordForIP(ip, name string) []msg.Service { | ||||
| 		} | ||||
| 		for _, eps := range ep.Subsets { | ||||
| 			for _, addr := range eps.Addresses { | ||||
| 				// The endpoint's Hostname will be set if this endpoint is supposed to generate a PTR. | ||||
| 				// So only return reverse records that match the IP AND have a non-empty hostname. | ||||
| 				// Kubernetes more or less keeps this to one canonical service/endpoint per IP, but in the odd event there | ||||
| 				// are multiple endpoints for the same IP with hostname set, return them all rather than selecting one | ||||
| 				// arbitrarily. | ||||
| 				if addr.IP == ip && addr.Hostname != "" { | ||||
| 					domain := strings.Join([]string{addr.Hostname, ep.Index, Svc, k.primaryZone()}, ".") | ||||
| 				if addr.IP == ip { | ||||
| 					domain := strings.Join([]string{endpointHostname(addr, k.endpointNameMode), ep.Index, Svc, k.primaryZone()}, ".") | ||||
| 					svcs = append(svcs, msg.Service{Host: domain, TTL: k.ttl}) | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
| @@ -60,10 +60,8 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints { | ||||
| 		Subsets: []object.EndpointSubset{ | ||||
| 			{ | ||||
| 				Addresses: []object.EndpointAddress{ | ||||
| 					{IP: "10.0.0.100", Hostname: "ep1a"}, // this endpoint is duplicated across two slices, which can happen in k8s | ||||
|  | ||||
| 					// 10.0.0.99 is used by two services. Only one will have hostname defined, as is typically enforced by K8s | ||||
| 					{IP: "10.0.0.99", Hostname: "double-ep"}, | ||||
| 					{IP: "10.0.0.100", Hostname: "ep1a"}, | ||||
| 					{IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services | ||||
| 				}, | ||||
| 				Ports: []object.EndpointPort{ | ||||
| 					{Port: 80, Protocol: "tcp", Name: "http"}, | ||||
| @@ -95,7 +93,7 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints { | ||||
| 		Subsets: []object.EndpointSubset{ | ||||
| 			{ | ||||
| 				Addresses: []object.EndpointAddress{ | ||||
| 					{IP: "10.0.0.100", Hostname: "ep1a"}, // This endpoint duplicated across used by two slices, see above | ||||
| 					{IP: "10.0.0.100", Hostname: "ep1a"}, // duplicate endpointslice address | ||||
| 				}, | ||||
| 				Ports: []object.EndpointPort{ | ||||
| 					{Port: 80, Protocol: "tcp", Name: "http"}, | ||||
| @@ -110,7 +108,7 @@ func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints { | ||||
| 		Subsets: []object.EndpointSubset{ | ||||
| 			{ | ||||
| 				Addresses: []object.EndpointAddress{ | ||||
| 					{IP: "10.0.0.99", Hostname: ""}, // This endpoint is used by two services, see above | ||||
| 					{IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services | ||||
| 				}, | ||||
| 				Ports: []object.EndpointPort{ | ||||
| 					{Port: 80, Protocol: "tcp", Name: "http"}, | ||||
| @@ -155,13 +153,6 @@ func TestReverse(t *testing.T) { | ||||
| 	k.APIConn = &APIConnReverseTest{} | ||||
|  | ||||
| 	tests := []test.Case{ | ||||
| 		{ | ||||
| 			Qname: "99.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | ||||
| 			Rcode: dns.RcodeSuccess, | ||||
| 			Answer: []dns.RR{ | ||||
| 				test.PTR("99.0.0.10.in-addr.arpa.      5    IN      PTR       double-ep.svc1.testns.svc.cluster.local."), | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | ||||
| 			Rcode: dns.RcodeSuccess, | ||||
| @@ -232,6 +223,14 @@ func TestReverse(t *testing.T) { | ||||
| 				test.SOA("cluster.local.       5     IN      SOA     ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 5"), | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			Qname: "99.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | ||||
| 			Rcode: dns.RcodeSuccess, | ||||
| 			Answer: []dns.RR{ | ||||
| 				test.PTR("99.0.0.10.in-addr.arpa.      5    IN      PTR       double-ep.svc1.testns.svc.cluster.local."), | ||||
| 				test.PTR("99.0.0.10.in-addr.arpa.      5    IN      PTR       double-ep.svc2.testns.svc.cluster.local."), | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	ctx := context.TODO() | ||||
| @@ -251,7 +250,7 @@ func TestReverse(t *testing.T) { | ||||
| 			t.Fatalf("Test %d: got nil message and no error for: %s %d", i, r.Question[0].Name, r.Question[0].Qtype) | ||||
| 		} | ||||
| 		if err := test.SortAndCheck(resp, tc); err != nil { | ||||
| 			t.Errorf("Test %d error: %s", i, err) | ||||
| 			t.Error(err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user