-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix for #368 #374
Fix for #368 #374
Conversation
Could you please drop all the import changes from the commits? For go projects it's a good idea to use the original repository in your go path but just add your fork as another remote, that way you don't have to change the imports when testing it locally. |
Will do...
On Oct 31, 2017 12:02, Mikkel Oscar Lyderik Larsen <notifications@github.com> wrote:
Could you please drop all the import changes from the commits?
For go projects it's a good idea to use the original repository in your go path but just add your fork as another remote, that way you don't have to change the imports when testing it locally.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#374 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AJAKlkJ1A-q8DHbtacApV32ze1yqExrFks5sx27VgaJpZM4QNNql>.
|
stashed, reset import changes, stash applied, commit'd, pushed... should be good now.. |
Thanks for your PR! Maybe you can try to rewrite your code more like this:
This would be easier to read it (at least for me). batchLimit could be somewhere else like moved to const, maybe even more configurable (but here I'm totally open). Also please add unit tests. |
The reason I wrote the function in the manner I did was to preserve the atomic nature of all related records by hostname. Currently all the A records are added first to the original CS, then all the TXT records are added to the CS and the entire batch is presumed atomic. If one were to just take the head or the tail of the original CS they would be violating the integrity that they were originally expecting. This said I'm happy to rework in any way desired. |
I think I can combine both ideas so it is an immediately complete scheme, as you wish. |
provider/aws.go
Outdated
@@ -254,6 +257,39 @@ func (p *AWSProvider) submitChanges(changes []*route53.Change) error { | |||
return nil | |||
} | |||
|
|||
func limitChangeSet(cs []*route53.Change) []*route53.Change { | |||
limit := 4000 |
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.
this should be a constant defined on the top of the file
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.
done
provider/aws.go
Outdated
for name, count := range countsByName { | ||
if (remaining - count) > 0 { | ||
remaining -= count | ||
for _, v := range cs { |
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.
as a minor optimisation countsByName, could be changesByName, then you don't have to iterate over whole set to find and append the records by name
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.
you lost me here - are you saying there already is a changesByName or are you saying for me to move my iteration out into its own function changesByName and call it instead?
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 idea was to create a map changesByName instead of countsByName:
changesByName := map[string][]*route53.Change
when u need a count, u can do len(changesByName[name])
, when u need to append:
limCs = append(limCs, changesByName[name]...)
please address two comments above, otherwise LGTM |
@ideahitme please merge if you approve |
done
________________________________
From: Yerken <notifications@github.com>
Sent: Thursday, November 2, 2017 3:50 PM
To: kubernetes-incubator/external-dns
Cc: Steven Logue; Author
Subject: Re: [kubernetes-incubator/external-dns] Fix for #368 (#374)
@ideahitme commented on this pull request.
________________________________
In provider/aws.go<#374 (comment)>:
+ }
+
+ log.Warningf("Initial change batch count is %d which exceeds %d", size, limit)
+
+ countsByName := make(map[string]int)
+ for _, v := range cs {
+ countsByName[*v.ResourceRecordSet.Name]++
+ }
+
+ var newCs = []*route53.Change{}
+
+ remaining := limit
+ for name, count := range countsByName {
+ if (remaining - count) > 0 {
+ remaining -= count
+ for _, v := range cs {
the idea was to create a map changesByName instead of countsByName:
changesByName := map[string][]*route53.Change
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#374 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AJAKlleFrquIIY4ACOZ5D5maTXV_Wpq4ks5sykdAgaJpZM4QNNql>.
|
thank you, looks good to me, however it would also be nice to see tests for the limitChangeSet function and AWS ApplyChanges |
thanks for the feedback! - tests coming :jackiechan: |
@ideahitme initial tests have been added - please comment |
provider/aws_test.go
Outdated
limCs := limitChangeSet(cs) | ||
|
||
limitedCount := len(limCs) | ||
assert.True(t, limitedCount == maxChangeCount, "limited changeset count=%d does not equal maxChangeCount=%d", limitedCount, maxChangeCount) |
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.
what I want to be sure of here, is that we do not accidentally end up with orphaned A or TXT record. I suggest to make the test more elaborate, for example by making limitChangeSet
take maxChangeCount
as a parameter. Consequently in test u can use a sane value like 4
or 6
and for test itself make sure that this limit is not exceeded and correct records are picked up.
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.
additionally having submitChanges
tested as well would be nice (test case with 4000+ records for one hosted zone)
d3627c1
to
f966288
Compare
} | ||
|
||
func sortChangesByActionNameType(cs []*route53.Change) []*route53.Change { | ||
sort.SliceStable(cs, func(i, j int) bool { |
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.
with this change travis builds will break on go1.7, but I think we can safely drop it from travis. Would u want to do it, or u want me to update it on this PR ?
two minor things:
otherwise LGTM |
@ideahitme - rebased, updated the changelog and travis and its all ready for you now... |
👍 |
1 similar comment
👍 |
All relevent changes are in aws.go