-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
RFC: Implement a handshake for VSock #1443
Conversation
The CI failed on coverage -0.1% and clippy test, you will need to increase it back. |
(Not a Firecracker maintainer, but work on firecracker-containerd) Firecracker-containerd ran into the same essential issue this RFC is addressing as we also use host-initiated connections to guest listeners, specifically to connect to TTRPC services running in the guest. We were able to workaround it by just having our guest listener always write an ack message back before it passed off an accepted connection to be used by the TTRPC server. That solution works for us given our particular use case only requires supporting Firecracker and we fully own the guest-side listener code (I'm guessing Kata has more requirements/complications than that), but it's not necessarily ideal and I appreciate the potential simplifications this RFC could introduce either way.
The overall idea here LGTM either way. |
7ce6075
to
c3087d2
Compare
d7cc885
to
ac4aeca
Compare
@sandreim I had got 87.8% in my part but just got 85.1% with default test. |
@teawater sorry for the late reply. We are currently in a business trip. What command do you use for getting the coverage? That seems like a big difference between our CI and your local machine. Usually we get a 0.1% difference if we run on different machines because for some weird reason kcov behaves differently on different platforms. I would suggest to take a look at the lines you introduced and check if they're all covered. If they're all covered, feel free to lower the coverage here:
|
This commit add a simple handshake interaction like WebSocket: A new command called Upgrade <port_num>\n to request connect port. hybrid vsock response 101\n (Switching Protocol) if connected. hybrid vsock response 504\n (Service Unavailable) if guest has not listened on the port. Signed-off-by: Hui Zhu <teawater@antfin.com>
Update test_peer_request and test_local_request in connection.rs. Add test_local_request_need_reply and test_local_request_timeout_need_reply to connection.rs. Add test_local_connection_with_upgrade, test_local_close_with_upgrade and test_local_connection_with_upgrade_get_oprst to muxer.rs. Signed-off-by: Hui Zhu <teawater@antfin.com>
@teawater Thanks for contributing and for the comprehensive description of the proposed solution! I agree that including a handshake does make for a more robust protocol here. In fact, at some point during development, we did have a simple handshake included, but that didn't make the final cut because the code was a bit messy and I underestimated its usefulness. Going forward, I think we should consider two key points. Separation of concernsThe vsock connection state machine ( Backwards compatibilityThe above solution gets a bit messy, because it has to support both the old I'm kinda inclined towards the clean-code-no-compat approach, so I'd like more opinions on the compatibility issue. Paging: @sboeuf , @sipsma , @firecracker-microvm/compute-capsule - I'd appreciate your input. |
On the backward-compatibility, we (@teawater and I) agree that a single |
@dhrgit hi! Sorry I couldn't review the discussion so far, I got busy... |
@dhrgit Will you post a new PR for current issue? |
@teawater
Yes I agree it is cleaner if we push the implementation down to each backend.
Oh yes please do that. I think this new |
Closing since the issue was addressed by #1472. |
This RFC implements a WebSocket-like upgrading for host-initiated vsock connection
Background
Currently the host-initiated vsock connection is initiated with a straight-fowward
CONNECT <port_num>\n;
command:This works like a charm if the sequence is correct. However, sometimes we don't know whether the guest listener has been deployed when we send the command in STEP 4. As a result, the connection connected in step 3 will be closed silently.
The issue we facing
In practice, we don't know the exact time we have set up the VSock connection successfully because there is no message talking about that. We have to write a dailer to check the message feedback from guest.
This dailer expects the server in guest send message out once it
accept
s the connection. However, for some servers like ttRPC, they won't send anything to the client. This makes trouble to the client dailer, which has toCONNECT
and assume the server has been deployed.Why not use guest-initiated vsock
We prefer host-initiated link because
The proposed handshake
What we proposed is a simple handshake interaction like WebSocket:
Upgrade <port_num>\n
on step 4;101\n
(Switching Protocol) if connected504\n
(Service Unavailable) if guest has not listened on the port.Then the dailer may retry/fail based on the explicit reponse.