-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multitarget #376
Multitarget #376
Changes from all commits
ffe076d
2d45bc2
e1dd79f
28fec84
2531925
837f376
6ac1b1a
612236d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,24 +65,16 @@ func (p *Plan) Calculate() *Plan { | |
continue | ||
} | ||
|
||
targetChanged := targetChanged(desired, current) | ||
shouldUpdateTTL := shouldUpdateTTL(desired, current) | ||
|
||
if !targetChanged && !shouldUpdateTTL { | ||
if !shouldUpdateTTL { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition skipped the record in case nothing was changed (target nor TTL). With this it skips the record whenever TTL was changed (but target could have) which seems wrong to me. Can you double-check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's really the crux of this PR -- don't turn |
||
log.Debugf("Skipping endpoint %v because nothing has changed", desired) | ||
continue | ||
} | ||
|
||
changes.UpdateOld = append(changes.UpdateOld, current) | ||
desired.MergeLabels(current.Labels) // inherit the labels from the dns provider, including Owner ID | ||
|
||
if targetChanged { | ||
desired.RecordType = current.RecordType // inherit the type from the dns provider | ||
} | ||
|
||
if !shouldUpdateTTL { | ||
desired.RecordTTL = current.RecordTTL | ||
} | ||
desired.MergeLabels(current.Labels) // inherit the labels from the dns provider | ||
desired.RecordType = current.RecordType // inherit the type from the dns provider | ||
|
||
changes.UpdateNew = append(changes.UpdateNew, desired) | ||
} | ||
|
@@ -109,10 +101,6 @@ func (p *Plan) Calculate() *Plan { | |
return plan | ||
} | ||
|
||
func targetChanged(desired, current *endpoint.Endpoint) bool { | ||
return desired.Target != current.Target | ||
} | ||
|
||
func shouldUpdateTTL(desired, current *endpoint.Endpoint) bool { | ||
if !desired.RecordTTL.IsConfigured() { | ||
return false | ||
|
@@ -123,7 +111,7 @@ func shouldUpdateTTL(desired, current *endpoint.Endpoint) bool { | |
// recordExists checks whether a record can be found in a list of records. | ||
func recordExists(needle *endpoint.Endpoint, haystack []*endpoint.Endpoint) (*endpoint.Endpoint, bool) { | ||
for _, record := range haystack { | ||
if record.DNSName == needle.DNSName { | ||
if record.DNSName == needle.DNSName && record.Target == needle.Target { | ||
return record, true | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test only work with TTL?
I think we should have a default defined in the zone, similar to DNS origin definition to default TTLs.
If it works, can we make this testcase to have with and without TTL tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TTLs are there in some tests now to have record updates rather than creations/deletions. Basically, with one Endpoint per (DNSName, Target), to update a record rather than delete it and create another one, you must not change either DNSName or Target, so I'm changing the TTL instead. If you change the target, the record won't be updated, it will be deleted and another one with the new target created -- similar to what would happen if you change the name. I have modified Plan.Calculate() to operate this way. (that's really the crux of this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks to clarify this