Skip to content

Commit 3af52c9

Browse files
[no-relnote] Fix device plugin API compatibility and field name casing
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent b9e9414 commit 3af52c9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

internal/plugin/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050

5151
// nvidiaDevicePlugin implements the Kubernetes device plugin API
5252
type nvidiaDevicePlugin struct {
53+
pluginapi.UnimplementedDevicePluginServer
5354
ctx context.Context
5455
rm rm.ResourceManager
5556
config *spec.Config
@@ -305,10 +306,10 @@ func (plugin *nvidiaDevicePlugin) GetPreferredAllocation(ctx context.Context, r
305306
func (plugin *nvidiaDevicePlugin) Allocate(ctx context.Context, reqs *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
306307
responses := pluginapi.AllocateResponse{}
307308
for _, req := range reqs.ContainerRequests {
308-
if err := plugin.rm.ValidateRequest(req.DevicesIDs); err != nil {
309+
if err := plugin.rm.ValidateRequest(req.DevicesIds); err != nil {
309310
return nil, fmt.Errorf("invalid allocation request for %q: %w", plugin.rm.Resource(), err)
310311
}
311-
response, err := plugin.getAllocateResponse(req.DevicesIDs)
312+
response, err := plugin.getAllocateResponse(req.DevicesIds)
312313
if err != nil {
313314
return nil, fmt.Errorf("failed to get allocate response: %v", err)
314315
}
@@ -399,7 +400,7 @@ func (plugin *nvidiaDevicePlugin) updateResponseForCDI(response *pluginapi.Conta
399400
cdiDevice := pluginapi.CDIDevice{
400401
Name: device,
401402
}
402-
response.CDIDevices = append(response.CDIDevices, &cdiDevice)
403+
response.CdiDevices = append(response.CdiDevices, &cdiDevice)
403404
}
404405
}
405406

internal/plugin/server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestAllocate(t *testing.T) {
4141
request: &pluginapi.AllocateRequest{
4242
ContainerRequests: []*pluginapi.ContainerAllocateRequest{
4343
{
44-
DevicesIDs: []string{"foo"},
44+
DevicesIds: []string{"foo"},
4545
},
4646
},
4747
},
@@ -60,7 +60,7 @@ func TestAllocate(t *testing.T) {
6060
request: &pluginapi.AllocateRequest{
6161
ContainerRequests: []*pluginapi.ContainerAllocateRequest{
6262
{
63-
DevicesIDs: []string{"foo", "bar", "foo"},
63+
DevicesIds: []string{"foo", "bar", "foo"},
6464
},
6565
},
6666
},
@@ -217,7 +217,7 @@ func TestCDIAllocateResponse(t *testing.T) {
217217
}
218218

219219
for i := range testCases {
220-
tc := testCases[i]
220+
tc := &testCases[i]
221221
t.Run(tc.description, func(t *testing.T) {
222222
deviceListStrategies, _ := v1.NewDeviceListStrategies(tc.deviceListStrategies)
223223
plugin := nvidiaDevicePlugin{

0 commit comments

Comments
 (0)