Add SessionPersistence API as experimental#2969
Add SessionPersistence API as experimental#2969k8s-ci-robot merged 4 commits intokubernetes-sigs:mainfrom
Conversation
|
Skipping CI for Draft Pull Request. |
bf40849 to
56a0446
Compare
144d3c6 to
377c4eb
Compare
|
@gcs278: GitHub didn't allow me to request PR reviews from the following users: ginayeh. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. |
| // | ||
| // When set to "Permanent", AbsoluteTimeout indicates the | ||
| // cookie's lifetime via the Expires or Max-Age cookie attributes | ||
| // and is required. |
There was a problem hiding this comment.
Should this requirement of having SessionPersistence.AbsoluteTimeout when SessionPersistence.LifetimeType = Permanent be enforced by CEL?
Or should we just allow implementations to decide a valid default?
There was a problem hiding this comment.
Good question, I think we should definitely aim to enforce this with CEL. Happy to help figure out what that looks like if it ends up being tricky.
There was a problem hiding this comment.
Added it.
I tested the CEL by hand in my own cluster with the CRD. Are there CRD integration tests for validating CEL that I should add a test case to? I looked around and couldn't find anything.
There was a problem hiding this comment.
Yep, sorry I missed this, these tests are part of https://github.com/kubernetes-sigs/gateway-api/tree/main/pkg/test/cel. Here's where we run them in presubmits:
gateway-api/hack/verify-crds-kind.sh
Line 60 in a101a23
There was a problem hiding this comment.
Ah should I looked a little harder...added a CEL test.
| // | ||
| // When set to "Permanent", AbsoluteTimeout indicates the | ||
| // cookie's lifetime via the Expires or Max-Age cookie attributes | ||
| // and is required. |
There was a problem hiding this comment.
Good question, I think we should definitely aim to enforce this with CEL. Happy to help figure out what that looks like if it ends up being tricky.
apis/v1/shared_types.go
Outdated
| // Support: Implementation-specific | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxLength=4096 |
There was a problem hiding this comment.
This seems like an awfully long length, what kind of session name would be this long?
There was a problem hiding this comment.
Good question...
I believe I got the max length from https://www.rfc-editor.org/rfc/rfc6265:
Practical user agent implementations have limits on the number and
size of cookies that they can store. General-use user agents SHOULD
provide each of the following minimum capabilities:o At least 4096 bytes per cookie (as measured by the sum of the
length of the cookie's name, value, and attributes).
But this is the minimum capabilities, so I suppose that's the worst case (smallest supported cookie size)...of the worst case (the entire cookie size is the name...).
So yea 4096 is a somewhat arbitrary. Is it best practice to limit string lengths? Or is it okay to leave unspecified?
There was a problem hiding this comment.
Is it best practice to limit string lengths?
Yep, it's been a strong requirement to avoid any kind of unbounded values in Gateway API.
as measured by the sum of the length of the cookie's name, value, and attributes
In the case of cookie-based persistence this would just be the cookie name right? (Not the value or attributes)
There was a problem hiding this comment.
In the case of cookie-based persistence this would just be the cookie name right? (Not the value or attributes)
Correct. SessionName is just the cookie name. I was just trying to find established limits, and the only one I came across was this 4096 bytes value for the whole cookie.
Since I can't find any enforced value, should we start with something reasonable? Maybe 128 or 256?
There was a problem hiding this comment.
Let's start with 128 and increase if/when necessary. It's hard for me to think of a use case that would require a longer session name, but I could be missing something.
There was a problem hiding this comment.
128 seems reasonable to start with. I suppose increasing the limit is much easier than decreasing the limit if we need to change it later.
| // Currently, Backends (i.e. Service, ServiceImport, or any | ||
| // implementation-specific backendRef) are the only valid API | ||
| // target references. | ||
| TargetRef PolicyTargetReference `json:"targetRef"` |
There was a problem hiding this comment.
I know you're already on this, but just in case we forget, when #2966 merges, we'll need to update this to be both a list and a local reference.
There was a problem hiding this comment.
As an experimental feature, does this belong in v1?
There was a problem hiding this comment.
Discussed in meeting, but since this is an experimental field and not an entire resource, we have to add it to any API versions that exist for that resource, in this case that includes v1. Importantly we add the <gateway:experimental> tags around this field to ensure it's only accessible if you install the experimental version of this CRD. This is conceptually similar to upstream Kubernetes where new fields added to the v1 Service API are initially guarded by alpha feature gates (but if that feature gate is enabled, the field is accessible as part of the v1 Service API).
4be3138 to
72ec6cd
Compare
| // Currently, Backends (i.e. Service, ServiceImport, or any | ||
| // implementation-specific backendRef) are the only valid API | ||
| // target references. | ||
| TargetRef LocalPolicyTargetReference `json:"targetRef"` |
There was a problem hiding this comment.
| TargetRef LocalPolicyTargetReference `json:"targetRef"` | |
| // +listType=map | |
| // +listMapKey=group | |
| // +listMapKey=kind | |
| // +listMapKey=name | |
| // +kubebuilder:validation:MinItems=1 | |
| // +kubebuilder:validation:MaxItems=16 | |
| TargetRefs []LocalPolicyTargetReference `json:"targetRefs"` |
I think this should be a list of object references, and I think this list should be "atomic" as I'd expect to exclusively have one owner, but interested in what others think here.
There was a problem hiding this comment.
listType=map with keys [group, kind, name] would make sense here. Then different parts of the list could be 'owned' by different people
There was a problem hiding this comment.
Sounds good, that likely is far more future proof. Somehow I'd convinced myself that these resources would always have a single owner, but there will likely be at least some edge cases where that's not true. I've updated the original suggestion to reflect your advice @dprotaso.
There was a problem hiding this comment.
Ack. Updated to be a list.
apis/v1/shared_types.go
Outdated
| // Support: Implementation-specific | ||
| // | ||
| // +optional | ||
| // +kubebuilder:validation:MaxLength=4096 |
There was a problem hiding this comment.
Let's start with 128 and increase if/when necessary. It's hard for me to think of a use case that would require a longer session name, but I could be missing something.
|
Thanks @gcs278! Will defer to someone else for final LGTM. /approve |
There was a problem hiding this comment.
Seems like a great huge step to getting something out there that implementations can try to implement and start giving us some feedback 👍
/approve
@gcs278 out of curiosity do you have an implementation that you tested this out with? If you do, would you be opposed to putting some time on our meeting agenda to do a quick demo for us? Would be really cool!
(also in general if you've had a chance to implement this locally and sort of try it out, that could be very valuable)
apis/v1/shared_types.go
Outdated
| // SessionPersistence defines the desired state of | ||
| // SessionPersistence. |
There was a problem hiding this comment.
| // SessionPersistence defines the desired state of | |
| // SessionPersistence. | |
| // SessionPersistence defines the desired state of SessionPersistence. |
| // the use a header or cookie. Defaults to cookie based session | ||
| // persistence. | ||
| // | ||
| // Support: Core for "Cookie" type |
| // | ||
| // Support: Core for "Cookie" type | ||
| // | ||
| // Support: Extended for "Header" type |
| // CookieConfig provides configuration settings that are specific | ||
| // to cookie-based session persistence. | ||
| // | ||
| // Support: Core |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gcs278, robscott, shaneutt The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
From GEP-1619, add BackendLBPolicy with SessionPersistence fields and add the SessionPersistence fields on HTTPRouteRule and GRPCRouteRule as experimental.
Add CEL to ensure absoluteTimeout is set when cookie lifetimeType is Permanent.
4a6d109 to
d2b23cf
Compare
I do not. I would love for an implementation to give this a shot. I will advertise for it in our community meeting.
+1 - that's one of the reasons I brought up Blitx as a reference implementation. I wish I had a "proving ground" for testing the API. I suppose it can be a real implementation. One of my concerns with the experimental API, is that it's mostly theoretical. I'm open to suggestions. |
- Add CEL validation tests - Update BackendLBPolicy to support list of TargetRefs - Change SessionName limit to 128 bytes
d2b23cf to
2f10b0a
Compare
|
Thanks @gcs278! /lgtm |
From GEP-1619, add BackendLBPolicy with SessionPersistence fields and add the SessionPersistence fields on HTTPRouteRule and GRPCRouteRule as experimental.
/kind feature
What this PR does / why we need it:
Makes SessionPersistence API experimental.
Which issue(s) this PR fixes:
Updates #713
Does this PR introduce a user-facing change?: