-
Notifications
You must be signed in to change notification settings - Fork 310
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
Record and pass stickiness cookies for load balancers #967
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
Hi @wjsi - thank you for opening this issue. It turns out that I am correctly working on a PR that will enable the ability to plugin your own "token renewer class" to allow for expiration tokens. In this PR, all aspects of the authorization header are configurable, and I would like to invite you to take a look at my local PR: kevin-bates#13. (I'm waiting for my colleagues to ensure the API satisfies their requirements, which is why I haven't submitted it to jupyter_server.) I'm hoping this approach would address your needs as well, but, if not, perhaps we can work together to arrive at a solution. |
@kevin-bates thanks for the quick reply. After reviewing your code I find it does not work for my case as the change is not in Current implementation of enterprise gateway requires clients to stick to one gateway node, and in k8s deployment this is achieved by using For the initial request, the client received a server identifier with some cookies. The load balancer decides subsequent nodes by the cookies sent by the client. Therefore I've written some code to show the changes can be done: main...wjsi:jupyter_server:enh/stickiness_cookie . |
Hi @wjsi - thank you for your detailed response. I agree that your need is more about cookie management in general and does not warrant the need for 3rd-party plugin functionality. Since this seems generally useful, I suggest you submit a pull request relative to your changes. I did have a couple of questions regarding those changes that might lead to some changes prior to the PR's creation.
We look forward to your pull request. Thank you for your contribution. |
@kevin-bates thanks for the comments. In the pull request I merged two options into |
Fixed in #969. |
Problem
Jupyter enterprise gateway now relies on Service.spec.sessionAffinity to make sure same backend pod is visited, which relies on client IP address to distribute pod access. However, when the environment becomes more complicated, for instance, service pods are hidden behind multiple layers of gateways or proxies, it is often not possible to locate the original client IP. Therefore kernels created on one pod will be lost when the load balancer chooses another pod when HA is not available, or a number of gateway pods are connected to the same kernel.
Proposed Solution
To resolve this issue, cloud providers like AWS provides a mechanism relying on client cookies to identify which server the client actually visits on their load balancers. When requesting with certain cookies, the load balancer will use the server used previously to hold the request.
To utilize this functionality, we need to record certain cookies (as well as expiration time) in
GatewayClient
when receiving responses from enterprise gateways, and add aCookie
header when doinggateway_request
.I'm now working on this in my own fork and would like to submit a PR for this.
The text was updated successfully, but these errors were encountered: