Skip to content

Commit

Permalink
add stop_soft_delete labels to geo endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Brookes <pbrookes@redhat.com>
  • Loading branch information
philbrookes committed Feb 26, 2025
1 parent 5557b54 commit 0aa46ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/builder/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/kuadrant/dns-operator/api/v1alpha1"
"github.com/kuadrant/dns-operator/internal/common/hash"
externaldnsplan "github.com/kuadrant/dns-operator/internal/external-dns/plan"
)

const (
Expand Down Expand Up @@ -237,12 +238,20 @@ func (builder *EndpointsBuilder) getLoadBalancedEndpoints() []*externaldns.Endpo
//Create lbName CNAME (lb-a1b2.shop.example.com -> <geoCode>.lb-a1b2.shop.example.com)
endpoint = createEndpoint(lbName, []string{geoLbName}, v1alpha1.CNAMERecordType, geoCode, DefaultCnameTTL)
endpoint.SetProviderSpecificProperty(v1alpha1.ProviderSpecificGeoCode, geoCode)
if endpoint.Labels == nil {
endpoint.Labels = externaldns.NewLabels()
}
endpoint.Labels[externaldnsplan.StopSoftDeleteLabel] = "true"
endpoints = append(endpoints, endpoint)

//Add a default geo (*) endpoint if the current geoCode is a default geo
if builder.loadBalancing.IsDefaultGeo {
endpoint = createEndpoint(lbName, []string{geoLbName}, v1alpha1.CNAMERecordType, "default", DefaultCnameTTL)
endpoint.SetProviderSpecificProperty(v1alpha1.ProviderSpecificGeoCode, WildcardGeo)
if endpoint.Labels == nil {
endpoint.Labels = externaldns.NewLabels()
}
endpoint.Labels[externaldnsplan.StopSoftDeleteLabel] = "true"
endpoints = append(endpoints, endpoint)
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/builder/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal(geo),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: geo}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 167 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal("klb.test." + domain),
Expand All @@ -172,6 +173,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal("default"),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: "*"}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 176 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal(HostOne(domain)),
Expand Down Expand Up @@ -213,6 +215,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal("default"),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: "*"}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 218 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal("klb." + domain),
Expand All @@ -221,6 +224,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal(geo),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: geo}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 227 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal(HostWildcard(domain)),
Expand Down Expand Up @@ -268,6 +272,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal("CAD"),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: "CAD"}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 275 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal(HostOne(domain)),
Expand Down Expand Up @@ -309,6 +314,7 @@ var _ = Describe("DnsrecordEndpoints", func() {
"SetIdentifier": Equal("CAD"),
"RecordTTL": Equal(endpoint.TTL(300)),
"ProviderSpecific": Equal(endpoint.ProviderSpecific{{Name: "geo-code", Value: "CAD"}}),
"Labels": HaveKeyWithValue(StopSoftDeleteLabel, "true"),

Check failure on line 317 in pkg/builder/endpoints_test.go

View workflow job for this annotation

GitHub Actions / Unit Test Suite

undefined: StopSoftDeleteLabel
})),
PointTo(MatchFields(IgnoreExtras, Fields{
"DNSName": Equal(HostWildcard(domain)),
Expand Down

0 comments on commit 0aa46ca

Please sign in to comment.