From df5e9aeacebe51dac7f71959fcf3bf0273fb19ef Mon Sep 17 00:00:00 2001 From: Matias Charriere Date: Thu, 15 Jun 2023 11:48:50 +0200 Subject: [PATCH] remove ForceUpdate property on endpoint after reimplementation Signed-off-by: Matias Charriere --- endpoint/endpoint.go | 13 +++++-------- internal/testutils/endpoint.go | 3 +-- plan/plan.go | 2 +- plan/plan_test.go | 25 ------------------------- 4 files changed, 7 insertions(+), 36 deletions(-) diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 46370fe5e..736f1e574 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -170,8 +170,6 @@ type Endpoint struct { Targets Targets `json:"targets,omitempty"` // RecordType type of record, e.g. CNAME, A, AAAA, SRV, TXT etc RecordType string `json:"recordType,omitempty"` - // Force planner to update record - ForceUpdate bool `json:"forceUpdate,omitempty"` // Identifier to distinguish multiple records with the same name and type (e.g. Route53 records with routing policies other than 'simple') SetIdentifier string `json:"setIdentifier,omitempty"` // TTL for the record @@ -204,12 +202,11 @@ func NewEndpointWithTTL(dnsName, recordType string, ttl TTL, targets ...string) } return &Endpoint{ - DNSName: strings.TrimSuffix(dnsName, "."), - Targets: cleanTargets, - RecordType: recordType, - ForceUpdate: false, - Labels: NewLabels(), - RecordTTL: ttl, + DNSName: strings.TrimSuffix(dnsName, "."), + Targets: cleanTargets, + RecordType: recordType, + Labels: NewLabels(), + RecordTTL: ttl, } } diff --git a/internal/testutils/endpoint.go b/internal/testutils/endpoint.go index fe13fb934..f8b465795 100644 --- a/internal/testutils/endpoint.go +++ b/internal/testutils/endpoint.go @@ -63,8 +63,7 @@ func SameEndpoint(a, b *endpoint.Endpoint) bool { a.Labels[endpoint.OwnerLabelKey] == b.Labels[endpoint.OwnerLabelKey] && a.RecordTTL == b.RecordTTL && a.Labels[endpoint.ResourceLabelKey] == b.Labels[endpoint.ResourceLabelKey] && a.Labels[endpoint.OwnedRecordLabelKey] == b.Labels[endpoint.OwnedRecordLabelKey] && - SameProviderSpecific(a.ProviderSpecific, b.ProviderSpecific) && - a.ForceUpdate == b.ForceUpdate + SameProviderSpecific(a.ProviderSpecific, b.ProviderSpecific) } // SameEndpoints compares two slices of endpoints regardless of order diff --git a/plan/plan.go b/plan/plan.go index e9aab6fb7..312bb261b 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -163,7 +163,7 @@ func (p *Plan) Calculate() *Plan { if row.current != nil && len(row.candidates) > 0 { // dns name is taken update := t.resolver.ResolveUpdate(row.current, row.candidates) // compare "update" to "current" to figure out if actual update is required - if shouldUpdateTTL(update, row.current) || targetChanged(update, row.current) || p.shouldUpdateProviderSpecific(update, row.current) || row.current.ForceUpdate { + if shouldUpdateTTL(update, row.current) || targetChanged(update, row.current) || p.shouldUpdateProviderSpecific(update, row.current) { inheritOwner(row.current, update) changes.UpdateNew = append(changes.UpdateNew, update) changes.UpdateOld = append(changes.UpdateOld, row.current) diff --git a/plan/plan_test.go b/plan/plan_test.go index f02a72d15..cc9e56bd5 100644 --- a/plan/plan_test.go +++ b/plan/plan_test.go @@ -51,7 +51,6 @@ type PlanTestSuite struct { domainFilterFiltered2 *endpoint.Endpoint domainFilterFiltered3 *endpoint.Endpoint domainFilterExcluded *endpoint.Endpoint - forceUpdate *endpoint.Endpoint } func (suite *PlanTestSuite) SetupTest() { @@ -231,12 +230,6 @@ func (suite *PlanTestSuite) SetupTest() { Targets: endpoint.Targets{"1.1.1.1"}, RecordType: "A", } - suite.forceUpdate = &endpoint.Endpoint{ - DNSName: "foo.domain.tld", - Targets: endpoint.Targets{"1.2.3.5"}, - RecordType: "A", - ForceUpdate: true, - } } func (suite *PlanTestSuite) TestSyncFirstRound() { @@ -650,24 +643,6 @@ func (suite *PlanTestSuite) TestDomainFiltersUpdate() { validateEntries(suite.T(), changes.Delete, expectedDelete) } -func (suite *PlanTestSuite) TestForceUpdate() { - current := []*endpoint.Endpoint{suite.forceUpdate} - desired := []*endpoint.Endpoint{suite.forceUpdate} - expectedUpdateOld := current - expectedUpdateNew := current - - p := &Plan{ - Policies: []Policy{&SyncPolicy{}}, - Current: current, - Desired: desired, - ManagedRecords: []string{endpoint.RecordTypeA, endpoint.RecordTypeCNAME}, - } - - changes := p.Calculate().Changes - validateEntries(suite.T(), changes.UpdateNew, expectedUpdateNew) - validateEntries(suite.T(), changes.UpdateOld, expectedUpdateOld) -} - func (suite *PlanTestSuite) TestAAAARecords() { current := []*endpoint.Endpoint{}