Skip to content
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

Merged

Conversation

justinsb
Copy link
Member

@justinsb justinsb commented Feb 3, 2020

For GCE this was resulting in confusing error messages.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 3, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2020
Copy link
Member

@johngmyers johngmyers left a 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
Copy link
Member

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.

Copy link
Member Author

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...

@justinsb
Copy link
Member Author

justinsb commented Apr 9, 2020

It should be the second contract, I believe. I'll add a comment and fix up the others!

@justinsb justinsb force-pushed the google_clouddns_delete_records branch from c22b4e9 to 19b47a0 Compare April 9, 2020 14:13
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/provider/digitalocean Issues or PRs related to digitalocean provider and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 9, 2020
@justinsb
Copy link
Member Author

justinsb commented Apr 9, 2020

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.

@justinsb justinsb force-pushed the google_clouddns_delete_records branch from 19b47a0 to 8028f38 Compare April 10, 2020 04:25
@johngmyers
Copy link
Member

Looks good, aside from the gofmt failure.

@justinsb justinsb added area/gce and removed area/provider/digitalocean Issues or PRs related to digitalocean provider labels May 17, 2020
justinsb and others added 2 commits May 17, 2020 16:43
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.
@justinsb justinsb force-pushed the google_clouddns_delete_records branch from 8028f38 to 868a025 Compare May 17, 2020 20:49
@k8s-ci-robot k8s-ci-robot added the area/provider/digitalocean Issues or PRs related to digitalocean provider label May 17, 2020
This was the root bug that was causing the over-logging on GCE.
@justinsb justinsb force-pushed the google_clouddns_delete_records branch from 868a025 to 3306549 Compare May 17, 2020 21:12
@johngmyers
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2020
@k8s-ci-robot k8s-ci-robot merged commit 2e5d476 into kubernetes:master May 17, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/gce area/provider/digitalocean Issues or PRs related to digitalocean provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants