mirror of
				https://github.com/kubernetes-sigs/external-dns.git
				synced 2025-10-31 18:50:59 +01:00 
			
		
		
		
	Do not merge CNAME targets into one endpoint per RFC-1034
This commit is contained in:
		
							parent
							
								
									ea6d44b0d8
								
							
						
					
					
						commit
						7e10c80323
					
				| @ -223,6 +223,7 @@ func (sc *serviceSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, e | ||||
| 			lastMergedEndpoint := len(mergedEndpoints) - 1 | ||||
| 			if mergedEndpoints[lastMergedEndpoint].DNSName == endpoints[i].DNSName && | ||||
| 				mergedEndpoints[lastMergedEndpoint].RecordType == endpoints[i].RecordType && | ||||
| 				mergedEndpoints[lastMergedEndpoint].RecordType != endpoint.RecordTypeCNAME && // It is against RFC-1034 for CNAME records to have multiple targets, so skip merging | ||||
| 				mergedEndpoints[lastMergedEndpoint].SetIdentifier == endpoints[i].SetIdentifier && | ||||
| 				mergedEndpoints[lastMergedEndpoint].RecordTTL == endpoints[i].RecordTTL { | ||||
| 				mergedEndpoints[lastMergedEndpoint].Targets = append(mergedEndpoints[lastMergedEndpoint].Targets, endpoints[i].Targets[0]) | ||||
|  | ||||
| @ -1260,13 +1260,37 @@ func testMultipleServicesEndpoints(t *testing.T) { | ||||
| 			map[string]string{}, | ||||
| 			"", | ||||
| 			map[string]map[string]string{ | ||||
| 				"a.elb.com": {hostnameAnnotationKey: "foo.example.org", SetIdentifierKey: "a"}, | ||||
| 				"b.elb.com": {hostnameAnnotationKey: "foo.example.org", SetIdentifierKey: "b"}, | ||||
| 				"1.2.3.5":  {hostnameAnnotationKey: "foo.example.org", SetIdentifierKey: "a"}, | ||||
| 				"10.1.1.3": {hostnameAnnotationKey: "foo.example.org", SetIdentifierKey: "b"}, | ||||
| 			}, | ||||
| 			[]string{}, | ||||
| 			[]*endpoint.Endpoint{ | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"a.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/fooa.elb.com"}, SetIdentifier: "a"}, | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"b.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/foob.elb.com"}, SetIdentifier: "b"}, | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeA, Targets: endpoint.Targets{"1.2.3.5"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/foo1.2.3.5"}, SetIdentifier: "a"}, | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeA, Targets: endpoint.Targets{"10.1.1.3"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/foo10.1.1.3"}, SetIdentifier: "b"}, | ||||
| 			}, | ||||
| 			false, | ||||
| 		}, | ||||
| 		{ | ||||
| 			"test that services with CNAME types do not get merged together", | ||||
| 			"", | ||||
| 			"", | ||||
| 			"testing", | ||||
| 			"foo", | ||||
| 			v1.ServiceTypeLoadBalancer, | ||||
| 			"", | ||||
| 			"", | ||||
| 			false, | ||||
| 			false, | ||||
| 			map[string]string{}, | ||||
| 			"", | ||||
| 			map[string]map[string]string{ | ||||
| 				"a.elb.com": {hostnameAnnotationKey: "foo.example.org"}, | ||||
| 				"b.elb.com": {hostnameAnnotationKey: "foo.example.org"}, | ||||
| 			}, | ||||
| 			[]string{}, | ||||
| 			[]*endpoint.Endpoint{ | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"a.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/fooa.elb.com"}}, | ||||
| 				{DNSName: "foo.example.org", RecordType: endpoint.RecordTypeCNAME, Targets: endpoint.Targets{"b.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/foob.elb.com"}}, | ||||
| 			}, | ||||
| 			false, | ||||
| 		}, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user