-
Notifications
You must be signed in to change notification settings - Fork 186
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
backend: Add websocket multiplexer #2459
Conversation
Backend Code coverage changed from 61.6% to 61.6%. Change: 0% 😃. Coverage report
|
Nice, tested it and it seems to work There are a couple of crucial things missing though:
|
Does this support webosocket connections other than watching resources, like attaching to the container? I've tried a path like this |
Thank you for the feedback @sniok. Awesome suggestions. I did forget to add closing the connection on request. Will add Regarding attaching, I did not try it. Will check why it’s not working. |
I think we can delay any work on attaching to the container if there is a problem. Because we mainly want this to help with watching. |
Hrmm. Not sure why this is at 0, since there are tests... lol. |
cf0f799
to
3971e72
Compare
Backend Code coverage changed from 61.5% to 60.8%. Change: -.7% 😞. Coverage report
|
Thanks for the changes.
Imagine we started watching two /pods from two different clusters (or two different ReplicaSets,etc) and we need to figure out where to put this update that we received from websocket. Currently we just get a Pod without any info where it came from
|
@sniok thank you for the detailed message. I have updated the description, screenshot, postman API and code. You will now have detailed information from where request is coming from. |
This adds websocket multiplexer to the backend. Frontend now make a single websocket call to the backend. Once that connection is established with the backend it will send message to the backend with appropriate data. Backend will open multiple websockets and act as a proxy to the frontend. It will make request to k8s server and return data to frontend. This also adds retry logic if the connection is broken between frontend and backend. Fixes: #1802 Signed-off-by: Kautilya Tripathi <[email protected]>
3971e72
to
bf2ec6d
Compare
Backend Code coverage changed from 61.5% to 61.1%. Change: -.4% 😞. Coverage report
|
Thanks @knrt10 (It looks like close can be used, and now a clusterID can be used to identify the response... Or is it also important to identify the specific request, rather than just the cluster?) Does it make sense to start implementing the frontend/ integration now? Will you do that? Note I started an issue here about multi cluster e2e tests here: |
Thanks for the explanation @knrt10 So the response returns (clusterID, path, query, and userID) as well as the data. This can be used to know from which websocket it comes from. We discussed the possibility that multiple ones could be made with the same of those... in this case it will not work. I don't think we need to cover this now though. It could be solved in the future by adding a separate unique ID for each one. Again, I don't think this is necessary for our use cases... we can use (clusterID, path, query, and userID) as the unique key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks
looks good, thanks! |
This adds websocket multiplexer to the backend. Frontend now need to make a single websocket call to the backend. Once that connection is established with the backend it will send message to the backend with appropriate data. Backend will open multiple websockets and act as a proxy to the frontend. It will make request to k8s server and return data to frontend.
This also adds retry logic if the connection is broken between frontend and backend.
Fixes: #1802
Testing
cd backend && go run ./cmd -dev -enable-dynamic-clusters
cd frontend && npm start
(we need this for userID of the session).Connect
buttonkubectl run nginx --image=nginx
and try other things like logs and execLogs
Exec
The data is sent as binary and it is encoded to bas64 to parse as JSON response.
Close connection
You can edit
path
as per your needs and check different output.