-
Notifications
You must be signed in to change notification settings - Fork 4.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
DNS: Don't try to apply empty changesets #8464
DNS: Don't try to apply empty changesets #8464
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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 is the interface contract?
Is it that the caller needs to check IsEmpty()
before calling Apply()
, in which case:
- All the other callers need to be fixed (unless they're proven to never generate empty changesets).
- The check inside of the GCE
Apply()
implementation is unnecessary and should be removed.
Or is it that the implementation of Apply()
needs to tolerate empty changesets, in which case:
- The check in the caller is unnecessary and should be removed.
- All of the other implementations of
Apply()
need to be fixed. - The
IsEmpty()
interface method is unnecessary and should be removed.
I believe the second contract is simpler and less prone to bugs.
@@ -115,7 +119,7 @@ func (c *ResourceRecordChangeset) Apply() error { | |||
} | |||
|
|||
func (c *ResourceRecordChangeset) IsEmpty() bool { | |||
return len(c.additions) == 0 && len(c.removals) == 0 | |||
return len(c.additions) == 0 && len(c.removals) == 0 && len(c.upserts) == 0 |
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.
Shouldn't there be a unit test for this, covering all of the implementations of the interface method? The only prior caller to this method I could find was a unit test for the case of it being empty. There should be tests for one addition, one removal, and one upsert.
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.
Yes, there should be. We inherited a lot of this code from k/k, and the design is pretty different from the rest of the code (even the rest of the code in k/k). It's hard to resist just rewriting the whole thing...
It should be the second contract, I believe. I'll add a comment and fix up the others! |
c22b4e9
to
19b47a0
Compare
Documented the contract, changed the signature to force a code change to every call & definition, added a generic test of the contract behaviour that was problematic. |
19b47a0
to
8028f38
Compare
Looks good, aside from the gofmt failure. |
For GCE this was resulting in confusing error messages.
Document the contract a bit more, change the signature by adding a context arg and following through to make sure we honor the contract everywhere.
8028f38
to
868a025
Compare
This was the root bug that was causing the over-logging on GCE.
868a025
to
3306549
Compare
/lgtm |
For GCE this was resulting in confusing error messages.