-
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
Ensure maximum run interval #1543
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sheerun The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @Raffo |
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.
Thank you for your PR @sheerun ! I added some comments.
controller/controller.go
Outdated
testing := false | ||
if v, ok := ctx.Value(nowValue).(time.Time); ok { | ||
now = v | ||
testing = 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.
What about having an early return here by testing the condition on line 131 instead of having multiple if statements like in line 144?
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.
Both ifs are on purpose the one on line 134 represents case when function is throttled, the one on line 144 represents case when function executes normally. We need both to properly test this function in tests. Please note that in one case error is returned and in other nil (error returned in tests means that function is trottled, nil returned means no throttling).
Co-Authored-By: Raffaele Di Fazio <raffo@github.com>
@sheerun do you want to have another look at this one? |
I think one more case needs to be handled: when RunOnceThottled is called during another executing of RunOnceThrottled is running, then we should call it one more time after first one finishes (e.g. if ingress is changed during updating of records, we should run reconciliation once again). Additional logic is also needed when ingress is updated multiple times (or multiple ingresses are updated) during updating of dns records. |
This pull request adds additional mechanism by which we can be sure synchronization won't run:
This is done by keeping track of whether RunOnce is already running, and what is next possible run time (i.e. one Interval since last time RunOnce has been called).
This can fix various issue like current one that causes RunOnce to be called twice when external-dns configured with
--events
runs, or multiple overlapping updates that can cause issues like #1463, especially if update time is for some reason longer than Interval (many records, network timeouts etc.)I've attached tests that test this behavior. I can also attest this works on real cluster (docker image at
sheerun/external-dns:v0.7.1-54-g98ac8302
).