Skip to content

Conversation

@salonichf5
Copy link
Contributor

@salonichf5 salonichf5 commented Dec 16, 2025

Proposed changes

Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:

Problem: Users need session persistence (“sticky sessions”) so traffic from the same client consistently routes to the same upstream instance for stateful apps.

Solution: Adds two types of session persistence: IP-based persistence by allowing users to set the ip_hash load-balancing method via the Upstream Settings Policy, and cookie-based persistence by adding support for sessionPersistence configuration at the Route level to enable sticky sessions using a sticky cookie. Cookie-based persistence is available only to NGINX Plus users and is supported in experimental mode. Additionally, the PR expands load-balancing support to include all methods available in both NGINX OSS and NGINX Plus.

Testing: Ensure pipeline succeeds. Functional test added.

Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.

Closes #2676

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation (update on doc side)
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Adds session persistence support for NGINX OSS and NGINX Plus. OSS and Plus users can configure `ip_hash` via `UpstreamSettingsPolicy` to provide client IP–based session affinity, while NGINX Plus users can configure `sessionPersistence` on `HTTPRoute` and `GRPCRoute` to enable cookie-based session persistence. Cookie-based session persistence is available only to NGINX Plus users and is currently in experimental mode.

@salonichf5 salonichf5 requested a review from a team as a code owner December 16, 2025 18:12
@github-actions github-actions bot added enhancement New feature or request tests Pull requests that update tests labels Dec 16, 2025
@salonichf5 salonichf5 changed the title Add support for Session Persistence for NGINX OSS and Plus Add Session Persistence support for NGINX OSS and Plus users Dec 16, 2025
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 92.01102% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.36%. Comparing base (5824970) to head (0f2ed98).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/controller/manager.go 0.00% 9 Missing ⚠️
internal/controller/state/graph/route_common.go 93.75% 4 Missing and 2 partials ⚠️
...ginx/config/policies/upstreamsettings/validator.go 88.88% 3 Missing and 2 partials ⚠️
...ernal/controller/nginx/config/validation/common.go 88.23% 3 Missing and 1 partial ⚠️
internal/controller/nginx/config/upstreams.go 93.75% 1 Missing and 1 partial ⚠️
internal/controller/state/graph/backend_refs.go 71.42% 1 Missing and 1 partial ⚠️
internal/controller/state/validation/validator.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4471      +/-   ##
==========================================
+ Coverage   86.25%   86.36%   +0.11%     
==========================================
  Files         132      132              
  Lines       14560    14849     +289     
  Branches       35       35              
==========================================
+ Hits        12558    12824     +266     
- Misses       1790     1806      +16     
- Partials      212      219       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sjberman
Copy link
Collaborator

Can you make the release note a bit more descriptive. It's okay if it's a few sentences. I'd like to be clear about what we support for each OSS and Plus.

@sjberman
Copy link
Collaborator

Do you also mind updating the PR description (and commit message) to also add some more detail on the two features that are added as part of this (LB methods and sessionPersistence support).

…4251)

Problem: Users want to specify load balancing method via Upstream Settings Policy API

Solution: Extend Upstream settings policy API to support load balancing method field.
Problem: Users want to be able to specify ip_hash load balancing for upstreams

Solution: Add support for session affinity using ip_hash directive in upstreams
Problem: Users want to specify all load balancing methods.

Solution: Specify a way for user to be able to specify all combinations of load balancing methods.
…y cookie` directive (#4305)

Problem: Users want to be able to specify session persistence for their upstreams.

Solution: Add support for session persistence using sticky cookie directives which is only available for NGINX Plus users.
Add functional tests for session persistence OSS and Plus
@salonichf5 salonichf5 force-pushed the feat/session-persistence branch from 58ff566 to 0f2ed98 Compare December 16, 2025 22:29
@salonichf5 salonichf5 enabled auto-merge (squash) December 16, 2025 22:36
@salonichf5 salonichf5 disabled auto-merge December 16, 2025 22:38
@salonichf5 salonichf5 enabled auto-merge (squash) December 16, 2025 22:39
@salonichf5 salonichf5 merged commit 852585e into main Dec 16, 2025
100 of 101 checks passed
@salonichf5 salonichf5 deleted the feat/session-persistence branch December 16, 2025 23:18
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in NGINX Gateway Fabric Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release-notes tests Pull requests that update tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

NGINX Plus and OSS: Session Persistence

4 participants