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

Fix panic on empty targets for custom resources. #1029

Merged
merged 3 commits into from
Jun 8, 2019

Conversation

arturo-c
Copy link
Contributor

Fixes #1027

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 15, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 15, 2019
@Raffo
Copy link
Contributor

Raffo commented May 19, 2019

Hi @arturo-c , thanks for your contribution. While your fix will definitely fix the panic, I'm not sure it would be the best change. Does it make sense to even allow an empty list of target? We should probably rather add validation to make sure that this can't happen at all.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 20, 2019
@arturo-c
Copy link
Contributor Author

@Raffo Added some checks for crd validation, let me know if thats what you were thinking

Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

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

lgtm @Raffo wdyt?

source/crd.go Outdated
@@ -117,7 +117,14 @@ func (cs *crdSource) Endpoints() ([]*endpoint.Endpoint, error) {
}

for _, dnsEndpoint := range result.Items {
endpoints = append(endpoints, dnsEndpoint.Spec.Endpoints...)
// Make sure that all endpoints have targets for A or CNAME type
for _, endPoint := range dnsEndpoint.Spec.Endpoints {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: please use endpoint instead of endPoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks for catching

@Raffo
Copy link
Contributor

Raffo commented Jun 8, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 8, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Raffo

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 Jun 8, 2019
@k8s-ci-robot k8s-ci-robot merged commit 58c9b2e into kubernetes-sigs:master Jun 8, 2019
@arturo-c arturo-c deleted the fix-panic-crd branch June 10, 2019 16:04
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.

When using custom CRDs to define an endpoint, a misconfigured resource makes external-dns panic
4 participants