Skip to content

Cookie affinity breaks for multiple ingresses on same host with different session-cookie-path #14042

@LevN0

Description

@LevN0

What happened:

When more than one ingress is defined for a single host, and at least two use the nginx.ingress.kubernetes.io/affinity: cookie annotation, if each of them uses a different nginx.ingress.kubernetes.io/session-cookie-path annotation, then those ingress' paths are load balanced randomly between the backend servers (ignoring the cookie affinity).

What you expected to happen:

I expected the load balancing would follow the cookie affinity.

The load balancing did not follow the cookie affinity, instead it was distributed randomly between the backend servers. I suspect the lua code doing the cookie affinity distribution does not account for this situation.

NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version): v1.12.7

Kubernetes version (use kubectl version): v1.31.13-eks-113cf36

How to reproduce this issue:

  1. Create 2 ingresses for the same host
    • Backend for each ingress should be the same, but pointing to at least 2 different servers
    • Set the nginx.ingress.kubernetes.io/affinity: cookie annotation on both
    • Set the nginx.ingress.kubernetes.io/session-cookie-path annotation on each, but different (in my case /path on one and /path/sub-path on other)
  2. Visit one of the load balanced paths repeatedly, find that the load balancing is distributing randomly between the backend servers

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions