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

nginx/proxy: allow specifying next upstream behaviour #907

Merged
merged 1 commit into from
Jun 27, 2017

Conversation

glerchundi
Copy link
Contributor

The motivation is that in our use case 504 http response is a valid user facing status code and nginx is retrying to all upstreams because it's inside the list of retryable errors (proxy_next_upstream):

https://github.com/kubernetes/ingress/blob/master/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl#L220

I didn't tested it yet because docker is retrying some image layers all the time but in case we can accelerate the acceptance-denying/review process here it is.

Should replace RetryNonIdempotent configuration.

WDYT?

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@glerchundi glerchundi changed the title nginx/proxy: allow specifying next upstream behaviour [WIP] nginx/proxy: allow specifying next upstream behaviour Jun 26, 2017
@glerchundi
Copy link
Contributor Author

Lots of work to be done but just to put it on the table and get feedback from you guys.

@aledbf aledbf self-assigned this Jun 26, 2017
@aledbf
Copy link
Member

aledbf commented Jun 26, 2017

@glerchundi you need to change the template (no reference int the PR).

Should replace RetryNonIdempotent configuration.

No. We need to keep the current defaults and allow the RetryNonIdempotent customization to the user

@aledbf
Copy link
Member

aledbf commented Jun 26, 2017

@glerchundi
Copy link
Contributor Author

@aledbf in case non_idempotent is defined by the user a warning appears indicating that a duplicate key was present:

2017/06/26 20:54:24 [warn] 1#1: duplicate value "non_idempotent" in /etc/nginx/nginx.conf:98
nginx: [warn] duplicate value "non_idempotent" in /etc/nginx/nginx.conf:98

I don't know if the extra logic to remove non_idempotent is worth it or not. Will do tomorrow in case it is.

Thanks for being that quick!

@glerchundi glerchundi changed the title [WIP] nginx/proxy: allow specifying next upstream behaviour nginx/proxy: allow specifying next upstream behaviour Jun 27, 2017
@glerchundi
Copy link
Contributor Author

@aledbf, in the case of non_idempotent we can choose between these options:

  1. Do nothing and let user fix ProxyNextUpstream & RetryNonIdempotent to conform a valid configuration file. nginx will complain with the error below.
  2. Always remove non_idempotent before using it and notifying the removal to the user with a warning which indicates that retry-non-idempotent should be used.
  3. Fail fast and don't allow non_idempotent in proxy-next-upstream.

I would choose the second one, WDYT?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 44.285% when pulling 1b3adb5 on glerchundi:master into 1468fcb on kubernetes:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 44.271% when pulling 1b3adb5 on glerchundi:master into 1468fcb on kubernetes:master.

@glerchundi
Copy link
Contributor Author

glerchundi commented Jun 27, 2017 via email

@@ -439,6 +436,9 @@ http {
proxy_cookie_domain {{ $location.Proxy.CookieDomain }};
proxy_cookie_path {{ $location.Proxy.CookiePath }};

# In case of errors try the next upstream server before returning an error
proxy_next_upstream {{ $location.Proxy.NextUpstream }}{{ if $cfg.RetryNonIdempotent }} non_idempotent{{ end }};
Copy link
Member

Choose a reason for hiding this comment

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

Please create a function in the file template.go in order to avoid non_idempotent duplication (if the user added that option to the default)

@aledbf
Copy link
Member

aledbf commented Jun 27, 2017

any chance to review and make it inside the next release? ;)

Please refactor the template with the function and I will test this asap

@glerchundi
Copy link
Contributor Author

glerchundi commented Jun 27, 2017

@aledbf addressed and squashed.

Note: already tested and works as expected.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 44.302% when pulling 5503e8d on glerchundi:master into 05e4600 on kubernetes:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 44.315% when pulling 5503e8d on glerchundi:master into 05e4600 on kubernetes:master.

func buildNextUpstream(input interface{}) string {
nextUpstream, ok := input.(string)
if !ok {
glog.Errorf("expected an string type but %T was returned", input)
Copy link
Member

@aledbf aledbf Jun 27, 2017

Choose a reason for hiding this comment

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

return the default values here (do not continue)

Edit: forget this commenr

@aledbf
Copy link
Member

aledbf commented Jun 27, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 27, 2017
@aledbf
Copy link
Member

aledbf commented Jun 27, 2017

@glerchundi thanks!

@aledbf aledbf merged commit 005ed52 into kubernetes:master Jun 27, 2017
@glerchundi
Copy link
Contributor Author

glerchundi commented Jun 28, 2017 via email

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. nginx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants