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

Resolve #4106, add check for empty certificate in get_pem_cert_key #4193

Closed
wants to merge 3 commits into from

Conversation

nr17
Copy link

@nr17 nr17 commented Jun 13, 2019

What this PR does / why we need it:
This PR fixes #4106

Special notes for your reviewer:
The original author's expectation might be that configuration.get_pem_cert_key(hostname) returns nil for the hostname when no tls section is defined for the corresponding ingress resource. But it seems to be returning empty string and this causes ssl.cert_pem_to_der(pem_cert_key) to fail later. This check fixes this issue.

@k8s-ci-robot
Copy link
Contributor

Welcome @nr17!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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 the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 13, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @nr17. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 13, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nr17
To complete the pull request process, please assign elvinefendi
You can assign the PR to them by writing /assign @elvinefendi in a comment when ready.

The full list of commands accepted by this bot can be found 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 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 Jun 13, 2019
@aledbf
Copy link
Member

aledbf commented Jun 13, 2019

@nr17 please change the description of the PR

@aledbf
Copy link
Member

aledbf commented Jun 13, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 13, 2019
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@8cee8d5). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4193   +/-   ##
=========================================
  Coverage          ?   57.77%           
=========================================
  Files             ?       87           
  Lines             ?     6479           
  Branches          ?        0           
=========================================
  Hits              ?     3743           
  Misses            ?     2306           
  Partials          ?      430

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cee8d5...5a04699. Read the comment docs.

@aledbf aledbf added this to In Progress in 0.25.0 Jun 13, 2019
@ElvinEfendi
Copy link
Member

Thanks for the PR!

It seems like under certain scenario controller pushes an empty certificate payload to Lua for a given host - certificate.lua module expects that if there's an entry for a given host then it must be a correct PEM cert. Empty payload, is an incorrect PEM cert therefore it expectedly fails.

IMHO this PR is not fixing the root cause of the problem. We should find out why the controller pushes empty payload for the host first and either make sure it pushes correct certificate (this will make sure things work as expected) or it does not push anything at all (in which case get_pem_cert_key will return nil and you will get the same result as this PR).

Can you write an e2e test first that describes the scenario with incorrect behaviour?

@nr17 nr17 changed the title Release 0.24.1 Resolve #4106, add check for empty certificate in get_pem_cert_key Jun 13, 2019
@nr17
Copy link
Author

nr17 commented Jun 13, 2019

Thanks for the PR!

It seems like under certain scenario controller pushes an empty certificate payload to Lua for a given host - certificate.lua module expects that if there's an entry for a given host then it must be a correct PEM cert. Empty payload, is an incorrect PEM cert therefore it expectedly fails.

IMHO this PR is not fixing the root cause of the problem. We should find out why the controller pushes empty payload for the host first and either make sure it pushes correct certificate (this will make sure things work as expected) or it does not push anything at all (in which case get_pem_cert_key will return nil and you will get the same result as this PR).

Can you write an e2e test first that describes the scenario with incorrect behaviour?

Yes, I had the same exact thoughts; but before investigating further, I wanted to get some feedback.

Also, I tried running the existing e2e tests with minikube, but for some reason I wasn't successful. Are the instructions at https://github.com/kubernetes/ingress-nginx/blob/master/docs/development.md up to date on running the tests. E.g. I noticed that make e2e-test requires "make e2e-test-image" to be executed first unless I am missing something. Can you give me some hints to have a setup with minikube where I can run e2e tests. I am not familiar with ginkgo.

@ElvinEfendi
Copy link
Member

ElvinEfendi commented Jun 13, 2019

@nr17 unfortunately it is out of date. What I do is

eval $(minikube docker-env)
make e2e-test-image

then

E2E_NODES=2 make e2e-test

you can also you FOCUS var when running e2e tests to focus on specific tests only because otherwise it takes forever. Another trick is to edit test/e2e/e2e.go and comment out all the test packages except the one that you want to run, then make sure you rebuild e2e test image before running again.

You can look at test/e2e/lua/dynamic_certificates.go for some inspiration.

@nr17
Copy link
Author

nr17 commented Jun 14, 2019

@nr17 unfortunately it is out of date. What I do is

eval $(minikube docker-env)
make e2e-test-image

then

E2E_NODES=2 make e2e-test

you can also you FOCUS var when running e2e tests to focus on specific tests only because otherwise it takes forever. Another trick is to edit test/e2e/e2e.go and comment out all the test packages except the one that you want to run, then make sure you rebuild e2e test image before running again.

You can look at test/e2e/lua/dynamic_certificates.go for some inspiration.

Thanks. I'll continue working on it.

nr17 added 2 commits June 15, 2019 12:51
secure-backends is supported now. backend-protocol will be ignored to avoid conflicts.
Add support for deprecated annotation
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 17, 2019
@k8s-ci-robot
Copy link
Contributor

@nr17: PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot removed the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 17, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 17, 2019
@k8s-ci-robot
Copy link
Contributor

@nr17: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-ingress-nginx-codegen accee08 link /test pull-ingress-nginx-codegen
pull-ingress-nginx-gofmt accee08 link /test pull-ingress-nginx-gofmt
pull-ingress-nginx-golint accee08 link /test pull-ingress-nginx-golint
pull-ingress-nginx-test-lua accee08 link /test pull-ingress-nginx-test-lua
pull-ingress-nginx-test accee08 link /test pull-ingress-nginx-test
pull-ingress-nginx-e2e-1-13 accee08 link /test pull-ingress-nginx-e2e-1-13
pull-ingress-nginx-e2e-1-14 accee08 link /test pull-ingress-nginx-e2e-1-14
pull-ingress-nginx-e2e-1-15 accee08 link /test pull-ingress-nginx-e2e-1-15

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@@ -46,20 +46,28 @@ func NewParser(r resolver.Resolver) parser.IngressAnnotation {
// ParseAnnotations parses the annotations contained in the ingress
// rule used to indicate the backend protocol.
func (a backendProtocol) Parse(ing *extensions.Ingress) (interface{}, error) {
klog.Infof("Parsing backend protocol annotation")
Copy link
Member

Choose a reason for hiding this comment

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

Please remove L49

if ing.GetAnnotations() == nil {
return HTTP, nil
}

// Proofpoint hack to make v0.24.1 compatible with deprecated "secure-backend" annotation
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this change. This annotation was removed in 0.21.0 #3203

@aledbf aledbf removed this from In Progress in 0.25.0 Jun 25, 2019
@nr17
Copy link
Author

nr17 commented Jun 25, 2019

Closing it as this has been fixed with #4229

@nr17 nr17 closed this Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sharing TLS config between ingresses
5 participants