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

Fix google dns for records with multiple targets #575

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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