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

Only set cookies on paths that enable session affinity #3383

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

zrdaley
Copy link
Contributor

@zrdaley zrdaley commented Nov 8, 2018

What this PR does / why we need it:

Session affinity is set on the a backend, not on the location path. This causes problems when multiple ingress definitions are created for the same host and not all enable session affinity.

Following this PR, session affinity cookies will only be set on paths with ingresses that have session affinity enabled.

Which issue this PR fixes: #3168

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 8, 2018
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 8, 2018
@zrdaley zrdaley changed the title Only set cookies on paths that enable session affinity [WIP] Only set cookies on paths that enable session affinity Nov 8, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 8, 2018
@zrdaley zrdaley changed the title [WIP] Only set cookies on paths that enable session affinity Only set cookies on paths that enable session affinity Nov 8, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 8, 2018
@zrdaley zrdaley force-pushed the affinity-fix branch 2 times, most recently from 9d1ecdc to 4ba2518 Compare November 9, 2018 14:29
@diazjf
Copy link

diazjf commented Nov 9, 2018

LGTM 👍

@k8s-ci-robot
Copy link
Contributor

@diazjf: Bad category. Please see https://api.thecatapi.com/api/categories/list

In response to this:

/meowvie cookies

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
Copy link
Contributor

@diazjf: Bad category. Please see https://api.thecatapi.com/api/categories/list

In response to this:

/meowvie psychedelic

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.

@zrdaley zrdaley force-pushed the affinity-fix branch 3 times, most recently from 3ceb2c2 to b5ddb00 Compare November 14, 2018 21:37
@zrdaley zrdaley force-pushed the affinity-fix branch 2 times, most recently from ffd651b to 86e0f69 Compare November 19, 2018 16:40
@ElvinEfendi
Copy link
Member

@zrdaley can you rebase with latest master so that this gets tested with your other merged session affinity change?

@zrdaley
Copy link
Contributor Author

zrdaley commented Nov 19, 2018

I already did @ElvinEfendi

@ElvinEfendi
Copy link
Member

/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 Nov 20, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ElvinEfendi, zrdaley

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 Nov 20, 2018
@k8s-ci-robot k8s-ci-robot merged commit e1780b4 into kubernetes:master Nov 20, 2018
@zrdaley zrdaley deleted the affinity-fix branch November 20, 2018 15:26
@unicast
Copy link

unicast commented Apr 2, 2019

@zrdaley what is expected behaviour if host is not specified and there are multiple Ingresses like that? Currently I'm not getting any cookie and I'm wondering whether it's a bug or a feature?

@zrdaley
Copy link
Contributor Author

zrdaley commented Apr 2, 2019

@unicast The current implementation expects a host, if it's not specified it won't set a cookie:
https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/lua/balancer/sticky.lua#L74-L78

@unicast
Copy link

unicast commented Apr 3, 2019

@zrdaley thanks for coming back so soon! This looks like a bug to me because host is an optional directive and all other features are supported there. I've created a bug with more details in there #3959, does it makes sense?

@lfundaro
Copy link

Hi @zrdaley ,

The current implementation expects a host, if it's not specified it won't set a cookie

Why is suddenly host a required parameter on the ingress definition. It's been always an optional parameter and by making it required it breaks backwards compatibility. 😕

@nusx
Copy link
Contributor

nusx commented Jun 21, 2019

If the host is specified and it's a wildcard, no session cookie will be set either.

This breaks our current setup.

We have:

  • an ingress definition with session affinity enabled, a wildcard hostname and multiple paths routing to individual backends.
  • another ingress definition without session affinity, with the same wildcard hostname for serving static content from a single service.

Having to specify each hostname leads to a multiplication of a large number of paths on both ingress definitions. The second ingress (serving static content) can no longer use wildcards - nginx will prefer the more specific hostnames and will no longer route traffic to the webserver.

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.

7 participants