Skip to content

add session persistence support in destination rule #3502

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ramaraochavali
Copy link
Contributor

@ramaraochavali ramaraochavali requested a review from a team as a code owner May 10, 2025 08:47
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 10, 2025
@ramaraochavali ramaraochavali added the release-notes-none Indicates a PR that does not require release notes. label May 10, 2025
@ramaraochavali
Copy link
Contributor Author

/test release-notes

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label May 11, 2025
@istio-testing
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@@ -495,6 +495,35 @@ message LoadBalancerSettings {
uint64 minimum_ring_size = 4 [deprecated=true];
};

// Session persistence settings for the destination. Use this for hard session affinity.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need very clear docs on the difference between this and consist hash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both 'hard affinity' and 'consistent hash' are well defined - but what we do ( 'by encoding the IP:port of the service in a cookie/header' ) needs to be clearly understood by users.

// Use a cookie to store the session affinity information.
COOKIE = 0;
// Use a header to store the session affinity information.
HEADER = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can this possibly be used? how would a client know the opaque value to put here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that opaque unfortunately - just an IP:port in a proto. I believe Envoy returns the header on the first request, and user is expected to set it in the next request.

Agree with your comment: it needs to be super clear in the comments, and also the case where we can't connect to the IP:port - don't remember if we return an error or just go to another endpoint and return the new updated header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Envoy returns the header with ip:port encoded and the client has to repeatedly send the header for every request.

The behaviour of Envoy when the ip:port is not found is dependent on the strict flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the docs to make all of this clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weak feature, mostly we istio should be transparent of applications

Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good in general - but needs more docs.

@@ -495,6 +495,35 @@ message LoadBalancerSettings {
uint64 minimum_ring_size = 4 [deprecated=true];
};

// Session persistence settings for the destination. Use this for hard session affinity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both 'hard affinity' and 'consistent hash' are well defined - but what we do ( 'by encoding the IP:port of the service in a cookie/header' ) needs to be clearly understood by users.

// Use a cookie to store the session affinity information.
COOKIE = 0;
// Use a header to store the session affinity information.
HEADER = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that opaque unfortunately - just an IP:port in a proto. I believe Envoy returns the header on the first request, and user is expected to set it in the next request.

Agree with your comment: it needs to be super clear in the comments, and also the case where we can't connect to the IP:port - don't remember if we return an error or just go to another endpoint and return the new updated header.


message Cookie {
// Lifetime of the cookie. If specified, a cookie with the TTL will be
// generated if the cookie is not present. If the TTL is present and zero,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember exactly - but there were some concerns with non-session cookies ( around privacy regulations - I think you are required to show the consent screen and all kind of other things ).

I would very much prefer if we start without this setting and only with session cookies, it's a very complicated problem, best to avoid Istio starting to set persistent cookies and dealing with privacy.

@costinm
Copy link
Contributor

costinm commented May 13, 2025

Not blocking for this CL, but few concerns I have with using DR:

  • normally DR can be used both by client (consumer) and producer. Envoy implements this in a strange way where the client can actually set cookies and implement persistence - because the client-sidecar can encode the endpoint IP, and server side can also do this by encoding their own IP, but AFAIK our implementation is client side. This may have changed - but needs to be clearly explained.

  • ambient with Waypoints may support this - but I think it should be configured with the Gateway API equivalent. Either way - we should document if it is supported/used/allowed in Waypoint.

  • same for Gateways (of both kinds).

@ramaraochavali
Copy link
Contributor Author

I am planning to support this for Sidecars and Gateways and also using Gateway API - Waypoints should use Gateway API to get this behaviour? Is that fine?

@costinm
Copy link
Contributor

costinm commented May 15, 2025 via email

// The cookie settings for session persistence.
Cookie cookie = 3;

message Cookie {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no cookie name needed?

// The type of session persistence to use.
Type type = 1;

// The name of the header or cookie to use for session persistence.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, see it. It is reusable field. Why donot we make header and cookie oneof

@costinm
Copy link
Contributor

costinm commented May 16, 2025 via email

@ramaraochavali
Copy link
Contributor Author

@howardjohn @costinm Sorry for the huge delay. Reading all the comments, it looks like the concern is more about adding more docs and explaining the behaviour in detail and there is no objection to this API. Is that a fair summary? If yes, I will work on adding more docs and address remaining comments, we can take it from there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR needs to be rebased before being merged release-notes-none Indicates a PR that does not require release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants