Skip to content

Commit

Permalink
Use WithContextDialer to replace WithDialer
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <kerthcet@gmail.com>
  • Loading branch information
kerthcet authored and elezar committed Jul 11, 2024
1 parent d00bf2b commit d9f202f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,13 @@ func (plugin *NvidiaDevicePlugin) PreStartContainer(context.Context, *pluginapi.

// dial establishes the gRPC communication with the registered device plugin.
func (plugin *NvidiaDevicePlugin) dial(unixSocketPath string, timeout time.Duration) (*grpc.ClientConn, error) {
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c, err := grpc.DialContext(ctx, unixSocketPath,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
// TODO: We need to switch to grpc.WithContextDialer.
//nolint:staticcheck
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("unix", addr, timeout)
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "unix", addr)
}),
)
if err != nil {
Expand Down

0 comments on commit d9f202f

Please sign in to comment.