mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 10:06:57 +02:00
do not merge endpoints with different set identifier
This commit is contained in:
parent
2f1aff4fe4
commit
c1af8a40ec
@ -221,6 +221,7 @@ func (sc *serviceSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, e
|
|||||||
lastMergedEndpoint := len(mergedEndpoints) - 1
|
lastMergedEndpoint := len(mergedEndpoints) - 1
|
||||||
if mergedEndpoints[lastMergedEndpoint].DNSName == endpoints[i].DNSName &&
|
if mergedEndpoints[lastMergedEndpoint].DNSName == endpoints[i].DNSName &&
|
||||||
mergedEndpoints[lastMergedEndpoint].RecordType == endpoints[i].RecordType &&
|
mergedEndpoints[lastMergedEndpoint].RecordType == endpoints[i].RecordType &&
|
||||||
|
mergedEndpoints[lastMergedEndpoint].SetIdentifier == endpoints[i].SetIdentifier &&
|
||||||
mergedEndpoints[lastMergedEndpoint].RecordTTL == endpoints[i].RecordTTL {
|
mergedEndpoints[lastMergedEndpoint].RecordTTL == endpoints[i].RecordTTL {
|
||||||
mergedEndpoints[lastMergedEndpoint].Targets = append(mergedEndpoints[lastMergedEndpoint].Targets, endpoints[i].Targets[0])
|
mergedEndpoints[lastMergedEndpoint].Targets = append(mergedEndpoints[lastMergedEndpoint].Targets, endpoints[i].Targets[0])
|
||||||
} else {
|
} else {
|
||||||
|
@ -1324,7 +1324,7 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
ignoreHostnameAnnotation bool
|
ignoreHostnameAnnotation bool
|
||||||
labels map[string]string
|
labels map[string]string
|
||||||
clusterIP string
|
clusterIP string
|
||||||
hostnames map[string]string
|
hostnames map[string][]string
|
||||||
serviceTypesFilter []string
|
serviceTypesFilter []string
|
||||||
expected []*endpoint.Endpoint
|
expected []*endpoint.Endpoint
|
||||||
expectError bool
|
expectError bool
|
||||||
@ -1342,8 +1342,8 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
false,
|
false,
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
"",
|
"",
|
||||||
map[string]string{
|
map[string][]string{
|
||||||
"1.2.3.4": "foo.example.org",
|
"1.2.3.4": {"foo.example.org", ""},
|
||||||
},
|
},
|
||||||
[]string{},
|
[]string{},
|
||||||
[]*endpoint.Endpoint{
|
[]*endpoint.Endpoint{
|
||||||
@ -1364,10 +1364,10 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
false,
|
false,
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
"",
|
"",
|
||||||
map[string]string{
|
map[string][]string{
|
||||||
"1.2.3.4": "foo.example.org",
|
"1.2.3.4": {"foo.example.org", ""},
|
||||||
"1.2.3.5": "foo.example.org",
|
"1.2.3.5": {"foo.example.org", ""},
|
||||||
"1.2.3.6": "foo.example.org",
|
"1.2.3.6": {"foo.example.org", ""},
|
||||||
},
|
},
|
||||||
[]string{},
|
[]string{},
|
||||||
[]*endpoint.Endpoint{
|
[]*endpoint.Endpoint{
|
||||||
@ -1388,14 +1388,14 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
false,
|
false,
|
||||||
map[string]string{},
|
map[string]string{},
|
||||||
"",
|
"",
|
||||||
map[string]string{
|
map[string][]string{
|
||||||
"1.2.3.5": "foo.example.org",
|
"1.2.3.5": {"foo.example.org", ""},
|
||||||
"10.1.1.3": "bar.example.org",
|
"10.1.1.3": {"bar.example.org", ""},
|
||||||
"10.1.1.1": "bar.example.org",
|
"10.1.1.1": {"bar.example.org", ""},
|
||||||
"1.2.3.4": "foo.example.org",
|
"1.2.3.4": {"foo.example.org", ""},
|
||||||
"10.1.1.2": "bar.example.org",
|
"10.1.1.2": {"bar.example.org", ""},
|
||||||
"20.1.1.1": "foobar.example.org",
|
"20.1.1.1": {"foobar.example.org", ""},
|
||||||
"1.2.3.6": "foo.example.org",
|
"1.2.3.6": {"foo.example.org", ""},
|
||||||
},
|
},
|
||||||
[]string{},
|
[]string{},
|
||||||
[]*endpoint.Endpoint{
|
[]*endpoint.Endpoint{
|
||||||
@ -1405,6 +1405,30 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"test that services with different set-identifier do not get merged together",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"testing",
|
||||||
|
"foo",
|
||||||
|
v1.ServiceTypeLoadBalancer,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
map[string]string{},
|
||||||
|
"",
|
||||||
|
map[string][]string{
|
||||||
|
"a.elb.com": {"foo.example.org", "a"},
|
||||||
|
"b.elb.com": {"foo.example.org", "b"},
|
||||||
|
},
|
||||||
|
[]string{},
|
||||||
|
[]*endpoint.Endpoint{
|
||||||
|
{DNSName: "foo.example.org", Targets: endpoint.Targets{"a.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/fooa.elb.com"}, SetIdentifier: "a"},
|
||||||
|
{DNSName: "foo.example.org", Targets: endpoint.Targets{"b.elb.com"}, Labels: map[string]string{endpoint.ResourceLabelKey: "service/testing/foob.elb.com"}, SetIdentifier: "b"},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.title, func(t *testing.T) {
|
t.Run(tc.title, func(t *testing.T) {
|
||||||
@ -1414,12 +1438,13 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
kubernetes := fake.NewSimpleClientset()
|
kubernetes := fake.NewSimpleClientset()
|
||||||
|
|
||||||
// Create services to test against
|
// Create services to test against
|
||||||
for serviceip, hostname := range tc.hostnames {
|
for lb, hostname := range tc.hostnames {
|
||||||
ingresses := []v1.LoadBalancerIngress{}
|
ingresses := []v1.LoadBalancerIngress{}
|
||||||
ingresses = append(ingresses, v1.LoadBalancerIngress{IP: serviceip})
|
ingresses = append(ingresses, v1.LoadBalancerIngress{IP: lb})
|
||||||
|
|
||||||
annotations := make(map[string]string)
|
annotations := make(map[string]string)
|
||||||
annotations[hostnameAnnotationKey] = hostname
|
annotations[hostnameAnnotationKey] = hostname[0]
|
||||||
|
annotations[SetIdentifierKey] = hostname[1]
|
||||||
|
|
||||||
service := &v1.Service{
|
service := &v1.Service{
|
||||||
Spec: v1.ServiceSpec{
|
Spec: v1.ServiceSpec{
|
||||||
@ -1428,7 +1453,7 @@ func testMultipleServicesEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Namespace: tc.svcNamespace,
|
Namespace: tc.svcNamespace,
|
||||||
Name: tc.svcName + serviceip,
|
Name: tc.svcName + lb,
|
||||||
Labels: tc.labels,
|
Labels: tc.labels,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user