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

Add FastCGI backend support (#2982) #4344

Merged
merged 1 commit into from
Jul 31, 2019
Merged

Add FastCGI backend support (#2982) #4344

merged 1 commit into from
Jul 31, 2019

Conversation

cdemers
Copy link
Contributor

@cdemers cdemers commented Jul 23, 2019

Co-authored-by: Pierrick Charron [email protected]

What this PR does / why we need it: Adds FastCGI backend support.

Which issue this PR fixes: fixes #2982

Special notes for your reviewer: This is our first implementation, any comments, insults and congratulations are very welcome.

@k8s-ci-robot
Copy link
Contributor

Welcome @cdemers!

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 k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 23, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @cdemers. 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 23, 2019
@aledbf
Copy link
Member

aledbf commented Jul 23, 2019

@cdemers thank you for working on this feature.

@aledbf
Copy link
Member

aledbf commented Jul 23, 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 Jul 23, 2019
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
nginx.ingress.kubernetes.io/fastcgi-params: "[\"SCRIPT_FILENAME /example/index.php\", \"HTTP_PROXY \\\"\\\"\"]"
Copy link
Member

Choose a reason for hiding this comment

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

We try to avoid this kind of annotation. Please use a configmap to store the configuration. Check https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#add-headers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an excellent suggestion! We did spend some time discussing this annotation and never thought about using a config map!

@@ -1295,6 +1295,16 @@ stream {
{{ range $errCode := $location.CustomHTTPErrors }}
error_page {{ $errCode }} = @custom_{{ $location.DefaultBackendUpstreamName }}_{{ $errCode }};{{ end }}

{{ if (eq $location.BackendProtocol "FCGI") }}
include /etc/nginx/fastcgi_params;
Copy link
Member

Choose a reason for hiding this comment

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

This file doesn't exist (we do not copy unnecessary files from the default directory.)
We need to copy /usr/local/openresty/nginx/conf/fastcgi_params to /etc/nginx

import (
"encoding/json"

extensions "k8s.io/api/extensions/v1beta1"
Copy link
Member

Choose a reason for hiding this comment

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

We replace this with k8s.io/api/networking/v1beta1. Make this change in all the files located in the PR

@aledbf
Copy link
Member

aledbf commented Jul 23, 2019

@cdemers please add e2e tests

@cdemers
Copy link
Contributor Author

cdemers commented Jul 23, 2019

Thanks for the comments! We'll get back with the corrections. I'm surprised that the pull-ingress-nginx-test failed however, it did work when we ran the tests (and compiled) locally. Any way, we'll find out what's happening, thanks again

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 26, 2019
@codecov-io
Copy link

codecov-io commented Jul 26, 2019

Codecov Report

Merging #4344 into master will increase coverage by 0.13%.
The diff coverage is 87.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4344      +/-   ##
==========================================
+ Coverage    58.5%   58.63%   +0.13%     
==========================================
  Files          87       88       +1     
  Lines        6528     6569      +41     
==========================================
+ Hits         3819     3852      +33     
- Misses       2281     2288       +7     
- Partials      428      429       +1
Impacted Files Coverage Δ
...ternal/ingress/annotations/backendprotocol/main.go 100% <ø> (ø) ⬆️
internal/ingress/types.go 0% <ø> (ø) ⬆️
internal/ingress/controller/template/template.go 83.48% <0%> (-0.46%) ⬇️
internal/ingress/types_equals.go 18.12% <0%> (-0.12%) ⬇️
internal/ingress/annotations/annotations.go 81.15% <100%> (+0.27%) ⬆️
internal/ingress/annotations/fastcgi/main.go 100% <100%> (ø)
internal/ingress/controller/controller.go 46.75% <100%> (+0.06%) ⬆️
internal/watch/file_watcher.go 80.76% <0%> (-3.85%) ⬇️
internal/ingress/metric/collectors/process.go 88.29% <0%> (-2.13%) ⬇️

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 25a293f...72271e9. Read the comment docs.

@aledbf
Copy link
Member

aledbf commented Jul 30, 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 Jul 30, 2019
@cdemers
Copy link
Contributor Author

cdemers commented Jul 31, 2019

@aledbf We left two commits so you could see what was changed after your comments, would you like us to squash them for the person who will /lgtm ?

@aledbf
Copy link
Member

aledbf commented Jul 31, 2019

@cdemers yes, please squash the commits

Co-authored-by: Pierrick Charron <[email protected]>
}

// NewNewFastCGIHelloServerDeploymentWithReplicas creates a new deployment of the
// fortune teller image in a particular namespace. Number of replicas is configurable
Copy link
Member

Choose a reason for hiding this comment

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

fortune teller image

is this actually fortune teller image?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, sorry, we missed this in the comments

f.WaitForNginxServer(host,
func(server string) bool {
return Expect(server).Should(ContainSubstring("fastcgi_param SCRIPT_FILENAME \"/home/www/scripts/php$fastcgi_script_name\";")) &&
Expect(server).Should(ContainSubstring("fastcgi_param REDIRECT_STATUS \"200\";"))
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to include the value of these env vars in response and assert on response (I realize that requires modifying the fastcgi hello world Go app)? IMHO that would be more "end-to-end" than asserting on configuration directive.

Copy link
Contributor

Choose a reason for hiding this comment

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

The last test in this file is the one which does the complete end-to-end proof. We did not wish to test all the annotations end-to-end because it made the test more fragile since it also tests nginx logic. Therefore, we did one full end-to-end test and the others have a slightly smaller scope, only testing that we are generating the correct configuration. If you prefer we can modify the hello image to include those variable to have every test be end-to-end.

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel too strongly about this.

@ElvinEfendi
Copy link
Member

ElvinEfendi commented Jul 31, 2019

/lgtm

Thanks for the feature!

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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 c8a3710 into kubernetes:master Jul 31, 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call for Discussion: FastCGI Support?
6 participants