New session_id_header for session affinity scorer plugin - #2238
New session_id_header for session affinity scorer plugin#2238D-Sai-Venkatesh wants to merge 13 commits into
Conversation
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
…terface Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
…header Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
…nity Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
…header tests Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
|
Will push one more commit which will move the |
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
|
Hey @liu-cong, just pushed a new commit to move the core session_id_header algorithm into a shared type in util/sessionaffinity so the scorer and filter both use it instead of each keeping a copy. Also added session_id_header to the filter. Let me know if any changes are required. |
| ) | ||
|
|
||
| // parameters configures the SessionAffinity filter. | ||
| type parameters struct { |
There was a problem hiding this comment.
I suggest the following refactor.
- Separate config struct for different strategy instead of a flat structure. This is clean and easy to extend.
- For the SessionIDStrategy, we should not by default look at the agent identity attribute. Session affinity plugins should be a self contained plugin and should not be tied to other plugins. We can let the user configure it explicitly.
- I propose we support multiple "session id sources" in priority order. This is very flexible - it allows the user to specify a header, and fallback to the agent id attribute for agent traffic.
type parameters struct {
// Strategy is StrategyEncodedEndpointHeader (the default) or
// StrategySessionID.
Strategy string `json:"strategy"`
// Only one of the strategies should be configured
EncordedEndpointHeaderConfig EncordedEndpointHeaderConfig
SessionIDConfig SessionIDConfig
}
// Shared between filter and corer, in util/sessionaffinity
type EncordedEndpointHeaderConfig struct {
// Name of the http header
// defaults to `x-session-token`
Header string `json:"header"`
}
type SessionIDConfig struct {
// If no sources are configured, defaults to http header `x-session-id`
// If multiple sources are configured, they are evaluated in priority order
Sources []SessionIDSource `json:"sources"`
// EvictionTTLSeconds is how long a session binding survives unused.
// session_id_header only.
EvictionTTLSeconds float64 `json:"evictionTtlSeconds"`
// EvictionSweepSeconds is how often expired bindings are swept.
// session_id_header only.
EvictionSweepSeconds float64 `json:"evictionSweepSeconds"`
}
type SessionIDSource struct {
// Only one of the following sources can be configured.
// Name of the http header
Header string `json:"header"`
// Name of the request attribute populated by upstream plugins
Attribute string `json:"attribute"`
}
There was a problem hiding this comment.
Thanks, implemented the above (per-strategy config, ordered sources, no implicit agent-identity fallback). The config types and resolution logic live in util/sessionaffinity for consumption by both the scorer and filter.
Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>
…orer Signed-off-by: Dasari Surya Sai Venkatesh <suryasai.venkatesh@gmail.com>

What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds a
session_id_headeralgorithm to thesession-affinity-scorerandsession-affinity-filter, picked with a newstrategyparam next to the existing defaultencoded_endpoint_header. Both algorithms now sit behind a small internalstrategyinterface (score/preRequest/responseHeader), so the plugin just delegates.The session ID comes from a request header, or from the attribute set by the agent-identity plugin. The scorer remembers which pod served that session and gives highest score for the same, dropping the mapping after a TTL if the session goes idle.
Which issue(s) this PR fixes:
Fixes #2019
Release note (write
NONEif no user-facing change):