Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #575 from mikenairn/563-fix_google_record_set_crea…
Browse files Browse the repository at this point in the history
…tion_with_multiple_targets

Fix google dns for records with multiple targets
  • Loading branch information
maleck13 authored Sep 19, 2023
2 parents 8d68f2a + b725800 commit 89c27b6
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/dns/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ func toResourceRecordSets(allEndpoints []*v1alpha1.Endpoint) []*dnsv1.ResourceRe
}
record.RoutingPolicy.Geo.Items = append(record.RoutingPolicy.Geo.Items, item)
}
records = append(records, record)
}
records = append(records, record)
}
return records
}
Expand Down
146 changes: 146 additions & 0 deletions pkg/dns/google/google_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,152 @@ func Test_toResourceRecordSets(t *testing.T) {
},
},
},
{
name: "Successful test weight round robin with multiple targets",
args: args{
allEndpoints: []*v1alpha1.Endpoint{
{
DNSName: "2c71gf.lb-4ej5le.unittest.google.hcpapps.net",
RecordType: "A",
RecordTTL: 60,
Targets: v1alpha1.Targets{
"0.0.0.0",
},
SetIdentifier: "",
},
{
DNSName: "lrnse3.lb-4ej5le.unittest.google.hcpapps.net",
RecordType: "A",
RecordTTL: 60,
Targets: v1alpha1.Targets{
"0.0.0.1",
},
SetIdentifier: "",
},
{
DNSName: "default.lb-4ej5le.unittest.google.hcpapps.net",
RecordType: "CNAME",
SetIdentifier: "2c71gf.lb-4ej5le.unittest.google.hcpapps.net",
RecordTTL: 60,
Targets: v1alpha1.Targets{
"2c71gf.lb-4ej5le.unittest.google.hcpapps.net",
},
ProviderSpecific: v1alpha1.ProviderSpecific{
v1alpha1.ProviderSpecificProperty{
Name: "weight",
Value: "120",
},
},
},
{
DNSName: "default.lb-4ej5le.unittest.google.hcpapps.net",
RecordType: "CNAME",
SetIdentifier: "lrnse3.lb-4ej5le.unittest.google.hcpapps.net",
RecordTTL: 60,
Targets: v1alpha1.Targets{
"lrnse3.lb-4ej5le.unittest.google.hcpapps.net",
},
ProviderSpecific: v1alpha1.ProviderSpecific{
v1alpha1.ProviderSpecificProperty{
Name: "weight",
Value: "120",
},
},
},
{
DNSName: "lb-4ej5le.unittest.google.hcpapps.net",
RecordType: "CNAME",
SetIdentifier: "default",
Targets: []string{
"default.lb-4ej5le.unittest.google.hcpapps.net",
},
RecordTTL: 300,
ProviderSpecific: v1alpha1.ProviderSpecific{
v1alpha1.ProviderSpecificProperty{
Name: "geo-code",
Value: "*",
},
},
},
{
DNSName: "unittest.google.hcpapps.net",
RecordType: "CNAME",
RecordTTL: 300,
Targets: []string{
"lb-4ej5le.unittest.google.hcpapps.net",
},
SetIdentifier: "",
},
},
},
want: []*dnsv1.ResourceRecordSet{
{
Name: "2c71gf.lb-4ej5le.unittest.google.hcpapps.net.",
Rrdatas: []string{
"0.0.0.0",
},
Ttl: 60,
Type: "A",
},
{
Name: "lrnse3.lb-4ej5le.unittest.google.hcpapps.net.",
Rrdatas: []string{
"0.0.0.1",
},
Ttl: 60,
Type: "A",
},
{
Name: "default.lb-4ej5le.unittest.google.hcpapps.net.",
RoutingPolicy: &dnsv1.RRSetRoutingPolicy{
Wrr: &dnsv1.RRSetRoutingPolicyWrrPolicy{
Items: []*dnsv1.RRSetRoutingPolicyWrrPolicyWrrPolicyItem{
{
Rrdatas: []string{
"2c71gf.lb-4ej5le.unittest.google.hcpapps.net.",
},
Weight: 120,
},
{
Rrdatas: []string{
"lrnse3.lb-4ej5le.unittest.google.hcpapps.net.",
},
Weight: 120,
},
},
},
},
Ttl: 60,
Type: "CNAME",
},
{
Name: "lb-4ej5le.unittest.google.hcpapps.net.",
RoutingPolicy: &dnsv1.RRSetRoutingPolicy{
Geo: &dnsv1.RRSetRoutingPolicyGeoPolicy{
EnableFencing: false,
Items: []*dnsv1.RRSetRoutingPolicyGeoPolicyGeoPolicyItem{
{
Location: "europe-west1",
Rrdatas: []string{
"default.lb-4ej5le.unittest.google.hcpapps.net.",
},
},
},
},
},
Ttl: 300,
Type: "CNAME",
},
{
Name: "unittest.google.hcpapps.net.",
Rrdatas: []string{
"lb-4ej5le.unittest.google.hcpapps.net.",
},
Ttl: 300,
Type: "CNAME",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 89c27b6

Please sign in to comment.