@@ -110,7 +110,7 @@ func (dp *DevicePlugin) Start() error {
110110 if err != nil {
111111 return fmt .Errorf ("failed to dial device plugin socket: %w" , err )
112112 }
113- conn .Close ()
113+ _ = conn .Close ()
114114
115115 // Register with kubelet
116116 if err := dp .register (); err != nil {
@@ -138,7 +138,9 @@ func (dp *DevicePlugin) register() error {
138138 if err != nil {
139139 return fmt .Errorf ("failed to dial kubelet: %w" , err )
140140 }
141- defer conn .Close ()
141+ defer func () {
142+ _ = conn .Close ()
143+ }()
142144
143145 client := pluginapi .NewRegistrationClient (conn )
144146 req := & pluginapi.RegisterRequest {
@@ -162,12 +164,8 @@ func (dp *DevicePlugin) register() error {
162164
163165// dial establishes a connection to a Unix socket
164166func (dp * DevicePlugin ) dial (unixSocketPath string , timeout time.Duration ) (* grpc.ClientConn , error ) {
165- ctx , cancel := context .WithTimeout (context .Background (), timeout )
166- defer cancel ()
167-
168- conn , err := grpc .DialContext (ctx , unixSocketPath ,
167+ conn , err := grpc .NewClient (unixSocketPath ,
169168 grpc .WithTransportCredentials (insecure .NewCredentials ()),
170- grpc .WithBlock (),
171169 grpc .WithContextDialer (func (ctx context.Context , addr string ) (net.Conn , error ) {
172170 return net .DialTimeout ("unix" , addr , timeout )
173171 }),
@@ -290,9 +288,7 @@ func (dp *DevicePlugin) Allocate(ctx context.Context, req *pluginapi.AllocateReq
290288
291289 // Compose allocation request
292290 deviceUUIDs := make ([]string , 0 , len (containerReq .DevicesIds ))
293- for _ , deviceID := range containerReq .DevicesIds {
294- deviceUUIDs = append (deviceUUIDs , deviceID )
295- }
291+ deviceUUIDs = append (deviceUUIDs , containerReq .DevicesIds ... )
296292
297293 allocReq := & api.DeviceAllocateRequest {
298294 WorkerUID : podUID ,
0 commit comments