Repository navigation
stateful session: new envelope stateful session extension - #39004
Conversation
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
cpakulski
left a comment
There was a problem hiding this comment.
I think I understand what you are trying to achieve here, but would you mind adding some examples to the PR description? What the client sends, what is received by the upstream server and what Envoy sends back to the client? Thanks!
|
@cpakulski thanks for the review. I will add a example for this. But if you get whatn I want to do now,would you mind also update the comments to see which comments are unnecessary to respond. Thanks. |
zhxie
left a comment
There was a problem hiding this comment.
It would be pretty useful for cascaded stateful session scenario, and some minor questions here.
|
Hi, @adisuissa ,could you also take a look at this PR as api-shepherds, maintainer and the code owner of stateful session extension when you get some free time? |
|
/retest |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks!
I've added some high-level comments to clarify the goal.
|
/retest |
cpakulski
left a comment
There was a problem hiding this comment.
Thanks for adding diagram.
So, it seems that this is not really MCP specific thing. Currently, header based statefulness works only for a single hop. This mechanism allows to specify statefulness across 1+ hops, but can also be used to completely change the meaning of the header, from desired IP to session-id.
I also think it is not an MCP specific seesion affinity issue, but more a backend-initiated-session case. If I'm missing anything let me know. |
|
Yeah. it is inspired by the MCP and one of the core targets of this PR is to cover the requirements of MCP. But it also could cover requirements of any protocol or scenarios that the same assumptions: the server will initialize the session and session id at initial request, the client will send the id back without modification at following requests. This is why I didn't call it MCP_MODE or something, because it's supersets of MCP. I thinks this point is described clearly in the PR's description. In all related contexts, the MCP is only an example protocol that the new mode could covers. |
|
By the way, the whole stateful session filter/feature could be treated as an extension for backend-initiated-session. |
As @adisuissa mentioned, in backend-initiated-session, it looks to me it is more complicated than the MCP case since it is using |
| // | ||
| // Only one of ``override_mode_config`` or ``packages_mode_config`` should be set. This is the | ||
| // default if no any mode config is set. | ||
| OverrideModeConfig override_mode_config = 2; |
There was a problem hiding this comment.
style-nit: consider having both modes in a Mode message (similar to oneof, but without a oneof). IMO it makes it a bit more readable, and the penalty isn't large.
| // session-header: "MS4yLjMuNDo4MDtvcmlnaW46eHh4eHh4Cg==" # base64("1.2.3.4:80;origin:xxxxxx") | ||
| // | ||
| // The ``origin`` part is used to store the original header value of ``name`` field specified | ||
| // header. And the ``origin`` part should always be last part of the new header value. |
There was a problem hiding this comment.
I think the ordering requirement is unnecessary, and complicates the interfaces. Other than simplifying the code, what's the motivation for keeping it the last element? The main reason is that adding ";cluster" or any other future component may change the ordering.
Moreover, it might be that a concatenation of 2 "origins" (e.g., 1.2.3.4:80;origin:abc;origin:xyz in case the upstream set abc;origin:xyz as the value of the header), may cause some ambiguity.
IT may be possible to use base64 again, and use a delimiter which will not be part of the value.
There was a problem hiding this comment.
keepping the origin at the last part is an easy way to ensure it could be safely to packages that multiple times by multiple envoy proxy.
for example: given a request with header value abc;origin:xyz;origin:xxx, the first envoy will split it to abc and xyz;origin:xxx and the second envoy will get xyz;origin:xxx from first envoy and split it to xyz and xxx.
And by this way we needn't to base64 the value from upstream again and again. This will simplify the debugging and mock test.
There was a problem hiding this comment.
I'm not sure I fully agree, and I think the current format adds a constraint on the allowed contents of the header value.
Say that the stateful-session-header name is ssheader, and that the upstream sends back the following ssheader value: ssheader:abc;origin:xyz (i.e., ssheader = abc;origin:xyz, which is a valid header value AFAIK).
This will be sent back to the downstream with the endpoint's address as follows 1.2.3.4:80;origin:ssheader:abc;origin:xyz. Now when the stateful-session filter parses this value, it will take the last part and forward the value of xyz.
There was a problem hiding this comment.
I may be missing something, but was this addressed, or was there any followup to this comment?
| } | ||
|
|
||
| // The packages mode config for the header based session state extension. | ||
| message PackagesModeConfig { |
There was a problem hiding this comment.
Brainstorming:
I wonder if there could be a better name than Packages mode, which is not so intuitive to me.
The closest thing I can think of is Matryoshka, but I wouldn't name it this way.
Things I can think of are related to Wrapper, Capsule (encapsulation), and Envelope.
WDYT?
There was a problem hiding this comment.
+1. Other options suggested before were: CASCADE or EXPAND.
There was a problem hiding this comment.
I have no strong point on the naming, I think Envelope sgtm.
|
/retest |
4 similar comments
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
|
/retest |
| TEST(HeaderBasedSessionStateFactoryTest, SessionStateTestInEnvelopeMode) { | ||
| { | ||
| HeaderBasedSessionStateProto config; | ||
| config.set_name("session-header"); |
There was a problem hiding this comment.
Would it make more sense to make this feature into its own stateful session extension, rather than trying to cram new behavior into the existing header based extension? Server initiated stateful sessions are sufficiently different to warrant its own extension.
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
9d1e3ca to
80e60e5
Compare
|
Force push becase i refactored everything. |
…e.proto Co-authored-by: Adi (Suissa) Peleg <[email protected]> Signed-off-by: code <[email protected]>
…e.proto Co-authored-by: Adi (Suissa) Peleg <[email protected]> Signed-off-by: code <[email protected]>
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
adisuissa
left a comment
There was a problem hiding this comment.
Thanks!
Left a couple of minor comments, but otherwise LGTM.
/lgtm api
Signed-off-by: wangbaiping(wbpcode) <[email protected]>
|
/retest |
1 similar comment
|
/retest |
…#39004) Signed-off-by: Ting Pan <[email protected]>
…eful session envelope, aiming to cover MCP 250326 spec SSE cherry-pick from envoyproxy#30573 envoyproxy@62f4a14#diff-c904f9b0d49cdd938ffaa952192372529415afa8602d7dc6acb904e61111d8a5 add strict mode to stateful session, return 503 when destination is not available cherry-pick from envoyproxy#32093 envoyproxy@6354dcf support 0 ttl in cookie stateful sessiion to disable cookie expiration Signed-off-by: 爵银 <[email protected]>
Commit Message: stateful session: new packages mode for header based session
Additional Description:
To close #38983
This mode is useful when the server will initialize the session and session id at initial request, the client will send the id back without modification at following requests.
More specifically, when the initial request is sent, the request doesn't contain session header. And the selected server will add a session-id in the response. And at all following requests in this same session, the request will carry this header.
Then, envoy will works in following way:
Note, this PR only cover the MCP 250326 spec. Because in the MCP 241105 spec, the session id generated by the server will be send back in the initial
endpointsse event. That means if we want to support MCP 241105, then we need to decode response body to append additional info to the session is and is a little more complex.But this principle is same. If MCP 241105 spec is necessary, you can create a simple Lua script to do it. You can decode the initial sse event at the
envoy_on_responseand update the session id. And extract the target host and original session id at theenvoy_on_request.Risk Level: low.
Testing: unit, integration.
Docs Changes: added.
Release Notes: added.
Platform Specific Features: n/a.