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

Multiple A records support for the same FQDN #1475

Merged
merged 5 commits into from
Apr 15, 2020

Conversation

ytsarev
Copy link
Member

@ytsarev ytsarev commented Mar 28, 2020

  • Fixes Update same domain name with multi IPs error #1313
  • Logic is to have unique key for every of multiple ep.Targets and keep
    them around in ep.Labels for further consistency
  • Unit test is not very strict as testing functions are not ready for
    multiple Services with the same key but is imho good enough

* Fixes kubernetes-sigs#1313
* Logic is to have unique key for every of multiple `ep.Targets` and keep
  them around in `ep.Labels` for further consistency
* Unit test is not very strict as testing functions are not ready for
  multiple Services with the same key but is imho good enough
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 28, 2020
ytsarev added a commit to k8gb-io/k8gb that referenced this pull request Mar 28, 2020
* Fixes #62
* Fixes kubernetes-sigs/external-dns#1313
* Upstream PR kubernetes-sigs/external-dns#1475
* Use custom build while upstream accepts the change
donovanmuller pushed a commit to k8gb-io/k8gb that referenced this pull request Mar 28, 2020
* Fixes #62
* Fixes kubernetes-sigs/external-dns#1313
* Upstream PR kubernetes-sigs/external-dns#1475
* Use custom build while upstream accepts the change
* Otherwise it would lead to unwanted deletion of etcd keys
* Inline func comment fix
@ytsarev
Copy link
Member Author

ytsarev commented Apr 2, 2020

/assign @Raffo

Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments, logic looks okay overall but there are some things that need to be addressed.
Did you have the chance to test this in a real cluster?

@@ -258,6 +258,28 @@ func NewCoreDNSProvider(domainFilter endpoint.DomainFilter, prefix string, dryRu
}, nil
}

// Find takes a Endpoint slice and looks for an element in it. If found it will
// return it's key, otherwise it will return -1 and a bool of false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// return it's key, otherwise it will return -1 and a bool of false.
// return its key, otherwise it will return -1 and a bool of false.

@@ -258,6 +258,28 @@ func NewCoreDNSProvider(domainFilter endpoint.DomainFilter, prefix string, dryRu
}, nil
}

// Find takes a Endpoint slice and looks for an element in it. If found it will
// return it's key, otherwise it will return -1 and a bool of false.
func findEp(slice []*endpoint.Endpoint, dnsName string) (int, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that you only use the Endpoint in https://github.com/kubernetes-sigs/external-dns/pull/1475/files#diff-5e7d0936cf66e74a78954bf63c9a428aR301-R302, what about making this return directly the Endpoint instead of the index and simplify https://github.com/kubernetes-sigs/external-dns/pull/1475/files#diff-5e7d0936cf66e74a78954bf63c9a428aR301-R303 ?

An alternative is to ditch this function completely and embed it in the Records function as it is very small.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raffo very good idea, I've implemented it in c9f22b4 .

}

// Find takes a ep.Targets string slice and looks for an element in it. If found it will
// return it's key, otherwise it will return -1 and a bool of false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code comment is wrong, this was likely a copy-paste, the function returns a string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raffo thanks for the catch, comments are fixed

@@ -311,6 +329,7 @@ func applyServiceChanges(provider coreDNSProvider, changes *plan.Changes) {
}

func validateServices(services, expectedServices map[string]*Service, t *testing.T, step int) {
t.Helper()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this line doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raffo without t.Helper() the stackrace points to the line in the function instead of the specific failing test where this function was used. So adding t.Helper() makes it much easier to understand which tests is exactly failing during the test run

@ytsarev
Copy link
Member Author

ytsarev commented Apr 8, 2020

I added a few comments, logic looks okay overall but there are some things that need to be addressed.
Did you have the chance to test this in a real cluster?

@Raffo Yes, it was end-to-end tested thoroughly before I sent PR. Currently we use external-dns with this modification in context of https://github.com/AbsaOSS/ohmyglb project. It's in use for a while, works as expected

* Return Endpoint instead of index in `findEp()`
* Simplify the logic within `Records()`
@ytsarev
Copy link
Member Author

ytsarev commented Apr 8, 2020

@Raffo All issues addressed, please check it out.

@ytsarev ytsarev requested a review from Raffo April 8, 2020 12:49
Copy link
Contributor

@Raffo Raffo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, please review my additional suggestions before we can merge this.

@@ -258,6 +258,28 @@ func NewCoreDNSProvider(domainFilter endpoint.DomainFilter, prefix string, dryRu
}, nil
}

// Find takes a Endpoint slice and looks for an element in it. If found it will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Find takes a Endpoint slice and looks for an element in it. If found it will
// findEp takes an Endpoint slice and looks for an element in it. If found it will

return nil, false
}

// Find takes a ep.Targets string slice and looks for an element in it. If found it will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Find takes a ep.Targets string slice and looks for an element in it. If found it will
// findLabelInTargets takes a ep.Targets string slice and looks for an element in it. If found it will

ep, found := findEp(result, dnsName)
if found {
ep.Targets = append(ep.Targets, service.Host)
log.Debugf("Exteding ep (%s) with new service host (%s)", ep, service.Host)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Debugf("Exteding ep (%s) with new service host (%s)", ep, service.Host)
log.Debugf("Extending ep (%s) with new service host (%s)", ep, service.Host)

@@ -305,7 +336,8 @@ func (p coreDNSProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
grouped[ep.DNSName] = append(grouped[ep.DNSName], ep)
}
for i, ep := range changes.UpdateNew {
ep.Labels[randomPrefixLabel] = changes.UpdateOld[i].Labels[randomPrefixLabel]
ep.Labels = changes.UpdateOld[i].Labels
log.Debugf("Updating labels (%s) with old labels(%s)", ep.Labels, changes.UpdateOld[i].Labels)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Debugf("Updating labels (%s) with old labels(%s)", ep.Labels, changes.UpdateOld[i].Labels)
log.Debugf("Updating labels (%s) with old labels(%s)", ep.Labels, changes.UpdateOld[i].Labels)

@ytsarev
Copy link
Member Author

ytsarev commented Apr 13, 2020

@Raffo thanks a lot for the catches. All fixed.

@Raffo
Copy link
Contributor

Raffo commented Apr 15, 2020

/lgmt
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Raffo, ytsarev

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 Apr 15, 2020
@ytsarev
Copy link
Member Author

ytsarev commented Apr 15, 2020

@Raffo you've made small typo so bot didn't put the label, s/lgmt/lgtm please :)

@Raffo
Copy link
Contributor

Raffo commented Apr 15, 2020

Merging PRs before coffee, always a bad idea.

@Raffo
Copy link
Contributor

Raffo commented Apr 15, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 15, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3487945 into kubernetes-sigs:master Apr 15, 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. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update same domain name with multi IPs error
3 participants