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 multiple non-matching canary #3839

Conversation

perprogramming
Copy link
Contributor

What this PR does / why we need it:
This PR fixes a bug where ingress-controller fails with a panic when trying to remove a non-matching alternative backend for the second time.
Panic occures when you for example apply a canary-ingress with multiple rules/pathes that both select the same backend but can both not be matched to another real backend by host & path.

Which issue this PR fixes: fixes #3838

Special notes for your reviewer:
The PR comes with an e2e test already. I had to add a new e2e-framework factory method, feel free to refactor.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2019
@perprogramming perprogramming force-pushed the bugfix/panic-on-multiple-non-matching-canary branch from ede8044 to 8a40e82 Compare March 4, 2019 11:31
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 4, 2019
@perprogramming
Copy link
Contributor Author

@strowi @frastel FYI

@aledbf
Copy link
Member

aledbf commented Mar 4, 2019

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2019
@@ -758,4 +758,28 @@ var _ = framework.IngressNginxDescribe("Annotations - canary", func() {
})
})
})

Context("Single canary Ingress with multiple paths to same backend", func() {
It("should work", func() {
Copy link
Member

@ElvinEfendi ElvinEfendi Mar 12, 2019

Choose a reason for hiding this comment

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

What about

It("does not crash when canary ingress has multiple paths to the same non-matching backend", ...)

without Context

I'd implement this as a unit test, but not feeling strongly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just tried to keep up with the structure of the rest of the file. I can remove the Context if preferred.

Copy link
Member

Choose a reason for hiding this comment

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

I can remove the Context if preferred.

yes, please

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

@@ -1224,6 +1224,11 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres

altUps := upstreams[upsName]

if altUps == nil {
klog.Errorf("alternative backend %s has already be removed", upsName)
Copy link
Member

Choose a reason for hiding this comment

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

Is this really an error? Maybe warn here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just tell me. I can change it in a bit!

Copy link
Member

Choose a reason for hiding this comment

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

let's make it a warning and fix the typo in the message:

alternative backend %s has already been removed

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

@ElvinEfendi
Copy link
Member

@perprogramming
Copy link
Contributor Author

I also added a warning for the catch-all block 👍

@perprogramming perprogramming force-pushed the bugfix/panic-on-multiple-non-matching-canary branch from f570fd2 to c995e13 Compare March 12, 2019 14:57
@ElvinEfendi
Copy link
Member

@perprogramming thanks for the patch!

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, ElvinEfendi, perprogramming

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 merged commit e624fe1 into kubernetes:master Mar 27, 2019
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.

Panic & CrashLoopBackoff when applying multiple non-matching canaries
4 participants