[client] Migrate deprecated grpc client code#4687
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the gRPC client code from the deprecated grpc.DialContext to grpc.NewClient, introducing manual connection management. The migration changes the connection establishment flow to explicitly connect and wait for readiness rather than blocking during dial. Additionally, the PR fixes a cleanup issue in the nbnet dialer where connection IDs weren't properly cleaned up on failed dial attempts.
Key changes:
- Replaced
grpc.DialContextwithgrpc.NewClientand added manual connection readiness checking - Fixed missing cleanup hook execution for failed dial attempts in the nbnet dialer
- Corrected documentation comments to accurately reflect that hooks execute after (not before) closing connections
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| client/grpc/dialer.go | Migrated from grpc.DialContext to grpc.NewClient with manual connection readiness waiting |
| client/grpc/dialer_generic.go | Removed unused parameters and redundant error logging in custom dialer |
| client/net/dialer_dial.go | Added cleanup call for failed dial attempts and simplified error message |
| client/net/conn.go | Refactored connection cleanup into separate function to support both successful and failed dial scenarios |
| client/net/listener_listen.go | Fixed documentation comments to correctly state hooks execute after closing |
| client/net/dial.go | Removed extraneous blank line |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
a9b9836 to
fc15625
Compare
|



Describe your changes
Migrates the code to use
grpc.NewClient, then connect and block manually. This leads to a small change in behavior; the dialer now gets the IP address passed instead of the hostname, leaving more control to grpc on which IP and family to pick for dialing.Also fixes a minor issue on hook cleanup for failed dial attempts in the nbnet dialer.
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__