-
Notifications
You must be signed in to change notification settings - Fork 142
DNR: Add session persistence support for NGINX Plus users using the sticky cookie directive
#4305
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
base: feat/session-persistence
Are you sure you want to change the base?
DNR: Add session persistence support for NGINX Plus users using the sticky cookie directive
#4305
Conversation
…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.
sticky cookie directivesticky cookie directive
| units := []unit{ | ||
| {"ms", 1}, | ||
| {"s", 1000}, | ||
| {"m", 60 * 1000}, | ||
| {"h", 60 * 60 * 1000}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can switch its order if we want larger units first.
| func equalSessionPersistenceConfig(a, b *SessionPersistenceConfig) bool { | ||
| if a == nil || b == nil { | ||
| return a == b | ||
| } | ||
| return a.Name == b.Name && | ||
| a.SessionType == b.SessionType && | ||
| a.Expiry == b.Expiry && | ||
| a.Path == b.Path | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about merging session persistence configs when overlapping fields are not present like we do for policies. But we do not have a large number of fields that get set here, so it did not make sense to me add more complexity here.
- we don't support idleTimeout
- absoluteTimeout required whenn cookie lifetime is permanent
- session name cannot be empty or else SP is not considered
- and we only configure session type
cookie
622cc92 to
ded1099
Compare
sticky cookie directivesticky cookie directive
|
FYI, the release note in the PR description isn't going to be used at all since this is being merged into the feature branch. For the main PR that we merge at the end, we'll want a descriptive release note to discuss the different ways session persistence is supported. |
|
See my comment on the other PR, I think we have to rethink this a bit to support a backend being referenced multiple times, to prevent unintended behavior or blocking desired behavior. |
sticky cookie directivesticky cookie directive
2d689a5 to
9863bd1
Compare
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 want to be able to specify session persistence for their upstreams.
Solution: Add support for session persistence using
sticky cookiedirectives which is only available for NGINX Plus usersTesting: Manual testing
Errors
Spec validation
Configuration
HTTPRoutes
Case 1: path and expires specified
Case 2 : no expiry, only path specified
Regular expression with other path matches (no path set)
Multiple matches with common prefix
multiple matches with no common prefix
GRPCRoutes (path is always empty for GRPCRoutes
Hostname matching
Exact Method matching
Conflicting Cases
HTTPRoute
Config only generated for v3 no conflict
Traffic splitting
config
GRPCRoute
Testing Session Persistence
Testing is done using a script by grabbing the cookie session id from the first request and using it in curl request to ensure each request goes to the same backend
HTTPRoutes (coffee -> sticky, tea -> regular)
Still Need to verify traffic splitting works with it or not.
GRPCRoutes (backend v1 --> normal, backend v2 --> sticky)
Each have 3 endpoints
Note:
RegularExpressionpath matches, we leave the cookie Path empty. A regex can match anywhere within the URL path (for example, /coffee/[A-Za-z]+/tea), so deriving a concrete cookie path from it would be misleading and could unintentionally restrict which requests send the cookie.sticky cookiedirective we need to resolve conflicts in session persistence pertaining to each rule that has a SP config and shares the same backend. No conflict is reported when backend ref shared across rules has a same SP configPlease 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 #4231
Checklist
Before creating a PR, run through this checklist and mark each as complete.
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.