-
Notifications
You must be signed in to change notification settings - Fork 612
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
Revamp GRPC Port forwarding tunnels to use existing proxy #2985
Conversation
pkg/portfwdserver/server.go
Outdated
return len(p), err | ||
} | ||
|
||
func (g GRPCServerRW) Read(p []byte) (n int, err error) { |
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.
Should we add a grpc module providing the server and client so we have the core of this code in one place? This will tiny dead code in the guest and host agent that may not be optimized out, but it will make it easier to understand and maintain when all the pieces are the same place.
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.
I understand the reason behind. But i don't think we can create a common one. As server and client are 2 different one. Create a common will create cyclic dependency as well.
At max we can do is, have a Base conn with method like setDeadline, setWriteDeadline etc. But for now i will avoid it. If you need for sure i can do that as well
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.
+1 to a base type.
} | ||
|
||
func (g GRPCServerRW) LocalAddr() net.Addr { | ||
return &net.UnixAddr{Name: "grpc", Net: "unixpacket"} |
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.
This seems like the right way to support good logging, better than the NamedReadWriter added in #2944.
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.
This is a pointless comment. The purpose of LocalAddr
is to identify the connection (which this doesn't do) while the NamedReadWriter
in #2944 is identifying the purpose of the connection.
This implementation here is a lie, it doesn't identify the connection and the address it returns cannot be used in any of the normal ways that net.Addr
is used.
} | ||
|
||
func (g GRPCServerRW) Close() error { | ||
return nil |
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.
Why this does nothing?
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.
Server doesn't have any stream closing methods. So it doesn't do anything
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.
So this is implemented only to satisfy the net.Conn interface? Should we log a debug message when about ignoring Close?
This code can be integrated in other code expecting that Close() does something. If doing nothing breaks something, the debug log will help to diagnose the issue.
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.
debug logs are useful only in dev side, also grpc server doesn't provide close, its purely handled on client itself. I don't think adding debug is anywhere useful.
I don't want to spam it in our guestagent logs which doesn't give much value.
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.
Returning nil on Close
is fine if there is nothing to do. SetDeadline
should return an error if it is not implemented.
} | ||
|
||
func (g GrpcClientRW) SetDeadline(t time.Time) error { | ||
return nil |
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.
Why we don't implement it? should we log a warning to make the issue visible?
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.
Too much logging will become a noise since these are connections. It will be called multiple times and its doesn't help much. SetDeadline is not even usecul in our case as ours is a grpc stream
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.
Or just panic. If these functions don't do what they're supposed to (and are never called) a panic would be proof of that.
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.
We cannot panic on all cases.
These are left as NO-OP wantedly. These methods may / will be called but its of no value to us as its a grpc tunnel wrapped conn
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.
no-op on SetDeadline is not a reasonable thing to do. It should return an error.
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.
@tamird Please understand the full flow before commenting. All left like that for a reason.
UDP Proxy internally will call SetReadDeadline so we cannot throw error. It will be no-op only. That's why all SetDeadline like methods are returning null.
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.
no-op on SetDeadline is not a reasonable thing to do. It should return an error.
I think you are talking past each other. SetDeadline()
must exist to implement the interface, but there is not actual implementation of that concept for this particular implementation (there is no deadline). Therefore the method does nothing. It doesn't mean it is an error; just a vestigial method that is not being used.
Since this change convert the GRPC endpoint to net.Con interface, why not use it with bcopy? #2944 It has the same terminating issue as tcpproxy, but at least it logs errors. It will be easier to fix it to return an error and terminate the copies. |
Ran DDEV Tests in buildkite. All tests passed https://buildkite.com/test-305/ddev/builds/19#01939bef-af2a-4b7d-9ea8-fa1ca461f037 |
48b2d5b
to
07d39e5
Compare
} | ||
|
||
func (g GRPCServerRW) LocalAddr() net.Addr { | ||
return &net.UnixAddr{Name: "grpc", Net: "unixpacket"} |
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.
This is a pointless comment. The purpose of LocalAddr
is to identify the connection (which this doesn't do) while the NamedReadWriter
in #2944 is identifying the purpose of the connection.
This implementation here is a lie, it doesn't identify the connection and the address it returns cannot be used in any of the normal ways that net.Addr
is used.
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.
I don't love this.
Delegating to a 3rd party library is a nice idea but as @nirs points out the error handling is subtle and in the case of this library, dubious. We also have to provide a largely fake interface implementation and instead of panicking (strict) we return nonsense (lax).
9a28bf8
to
0be4bc1
Compare
@nirs & @tamird - Updated logic to use bicopy. Re-verified the ddev run as well |
Signed-off-by: Balaji Vijayakumar <[email protected]>
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
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [lima-vm/lima](https://github.com/lima-vm/lima) | patch | `v1.0.2` -> `v1.0.3` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>lima-vm/lima (lima-vm/lima)</summary> ### [`v1.0.3`](https://github.com/lima-vm/lima/releases/tag/v1.0.3) [Compare Source](lima-vm/lima@v1.0.2...v1.0.3) #### Changes - QEMU: - Support Apple M4 ([#​3032](lima-vm/lima#3032)) - gRPC port forwarder: - Improvements on stability ([#​2971](lima-vm/lima#2971), [#​2985](lima-vm/lima#2985), etc. thanks to [@​nirs](https://github.com/nirs) [@​balajiv113](https://github.com/balajiv113)) - Templates: - `archlinux`: allow 9p again ([#​3048](lima-vm/lima#3048)) - `centos-stream-10`: New template ([#​3023](lima-vm/lima#3023), [#​3047](lima-vm/lima#3047), thanks to [@​afbjorklund](https://github.com/afbjorklund)) - `opensuse`: disable virtiofs due to the lack of the kernel module in the default installation ([#​3056](lima-vm/lima#3056)) - Updated to the latest revisions ([#​3043](lima-vm/lima#3043)) Full changes: https://github.com/lima-vm/lima/milestone/52?closed=1 Thanks to [@​PascalBourdier](https://github.com/PascalBourdier) [@​afbjorklund](https://github.com/afbjorklund) [@​alexandear](https://github.com/alexandear) [@​balajiv113](https://github.com/balajiv113) [@​cpick](https://github.com/cpick) [@​jandubois](https://github.com/jandubois) [@​nirs](https://github.com/nirs) [@​olamilekan000](https://github.com/olamilekan000) #### Usage ```console [macOS]$ limactl create [macOS]$ limactl start ... INFO[0029] READY. Run `lima` to open the shell. [macOS]$ lima uname Linux ``` *** The binaries were built automatically on GitHub Actions. The build log is available for 90 days: https://github.com/lima-vm/lima/actions/runs/12517401436 The sha256sum of the SHA256SUMS file itself is `69423d9f9044fc9264925d24cd38c1d0efb4367cfb46c568313f53d6f0ed7ee2` . *** Release manager: [@​AkihiroSuda](https://github.com/AkihiroSuda) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44My4zIiwidXBkYXRlZEluVmVyIjoiMzkuODMuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes #2968 and several GRPC port forwarding issues.
FYI - Running ddev testsuite to verify end-end (Done)
https://buildkite.com/test-305/ddev/builds/19#01939bef-af2a-4b7d-9ea8-fa1ca461f037