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

if alternate access two ingress paths, the session can't keep sticky #1930

Closed
hebo1982 opened this issue Jan 19, 2018 · 4 comments · Fixed by #2451
Closed

if alternate access two ingress paths, the session can't keep sticky #1930

hebo1982 opened this issue Jan 19, 2018 · 4 comments · Fixed by #2451
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@hebo1982
Copy link

hebo1982 commented Jan 19, 2018

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.):

What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):


Is this a BUG REPORT or FEATURE REQUEST? (choose one):
FEATURE REQUEST

NGINX Ingress controller version:0.9.0-beta.11

Kubernetes version (use kubectl version):1.5.2

Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): Linux version 3.10.0-693.11.6.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) )
  • Kernel (e.g. uname -a):Linux 3.10.0-693.11.6.el7.x86_64
  • Install tools:yum install
  • Others:

What happened:
my deploy yaml

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: mooc-pre
  name: mooc-pre
  namespace: pre
  annotations:
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/affinity: "cookie"
    ingress.kubernetes.io/session-cookie-name: "k8s"
    ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
  rules:
  - host: mooc1-k8s.chaoxing.com
    http:
      paths:
      - path: /ananas
        backend:
          serviceName: tomcat1
          servicePort: 8080
      - path: /
        backend:
          serviceName: tomcat2
          servicePort: 8080

I have 2 tomcat projects.
when visited "https://mooc1-k8s.chaoxing.com/test.jsp" i got k8s cookie, but i visited "https://mooc1-k8s.chaoxing.com/ananas/test.jsp" i got a new k8s cookie and
session missed.

like nginx-sticky:
https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng

 sticky [name=route] [domain=.foo.bar] [path=/] [expires=1h] 
       [hash=index|md5|sha1] [no_fallback] [secure] [httponly];

how to set path?

What you expected to happen:
k8s cookie should not changed.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know:

@hebo1982
Copy link
Author

hebo1982 commented Jan 19, 2018

---
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: mooc-pre
  name: mooc-pre
  namespace: pre
  annotations:
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/affinity: "cookie"
    ingress.kubernetes.io/session-cookie-name: "k8s-2"
    ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
  rules:
  - host: mooc1-k8s.chaoxing.com
    http:
      paths:
      - path: /
        backend:
          serviceName: tomcat2
          servicePort: 8080
---
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  labels:
    app: html-editor-a-pre
  name: html-editor-a-pre
  namespace: pre
  annotations:
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/affinity: "cookie"
    ingress.kubernetes.io/session-cookie-name: "k8s-1"
    ingress.kubernetes.io/session-cookie-hash: "sha1"
spec:
  rules:
  - host: mooc1-k8s.chaoxing.com
    http:
      paths:
      - path: /ananas
        backend:
          serviceName: tomcat1
          servicePort: 8080

I solve that use two "ingress.kubernetes.io/session-cookie-name: k8s-X"

@Atoms
Copy link
Contributor

Atoms commented Feb 9, 2018

yes, have same problem, and i found where the problem is in code:

sticky hash={{ $upstream.SessionAffinity.CookieSessionAffinity.Hash }} name={{ $upstream.SessionAffinity.CookieSessionAffinity.Name }} httponly;

it does not use all parameters from nginx-sticky-module-ng

nusx added a commit to nusx/ingress-nginx that referenced this issue Apr 30, 2018
…ple rules and backends

* for an ingress with session affinity cookie, set the location as path on the cookie when unique
* the previous behaviour ( cookie path=/ ) is preserved for ingresses with multiple rules for the same backend (locations not unique)
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 10, 2018
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 9, 2018
nusx added a commit to nusx/ingress-nginx that referenced this issue Jun 11, 2018
…ple rules and backends

* for an ingress with session affinity cookie, set the location as path on the cookie when unique
* the previous behaviour ( cookie path=/ ) is preserved for ingresses with multiple rules for the same backend (locations not unique)

added e2e tests for session affinity, setting path on sticky config

added tests:
* it should set the path to /something on the generated cookie
* it should set the path to / on the generated cookie if there's more than one rule referring to the same backend
k8s-ci-robot added a commit that referenced this issue Jun 15, 2018
fix for #1930, make sessions sticky, for ingress with multiple rules …
fmejia97 pushed a commit to Shopify/ingress that referenced this issue Jun 18, 2018
…ple rules and backends

* for an ingress with session affinity cookie, set the location as path on the cookie when unique
* the previous behaviour ( cookie path=/ ) is preserved for ingresses with multiple rules for the same backend (locations not unique)

added e2e tests for session affinity, setting path on sticky config

added tests:
* it should set the path to /something on the generated cookie
* it should set the path to / on the generated cookie if there's more than one rule referring to the same backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants