Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/dra-example-kubeletplugin/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"k8s.io/dynamic-resource-allocation/resourceslice"

"k8s.io/klog/v2"
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1beta1"
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember choosing not to do this sooner since it changes the format of checkpoints on disk: #123 (comment). I'm not really sure what the implications of that are, especially w.r.t. driver upgrades.

@bart0sh @klueska @pohly How should drivers generally be utilizing checkpoints? Is this the right way to integrate the share_id of a device into the checkpoint?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should use a format that is entirely under their own control, ideally using versioning to enable conversion if the driver needs to change the format.

The kubelet checkpointing code is seriously flawed because it checksums the in-memory representation. See discussion in #90 (comment).

cdiapi "tags.cncf.io/container-device-interface/pkg/cdi"

checkpointapi "sigs.k8s.io/dra-example-driver/internal/api/checkpoint"
Expand Down
16 changes: 15 additions & 1 deletion cmd/dra-example-kubeletplugin/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1beta1"
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1"
"k8s.io/utils/ptr"

"sigs.k8s.io/dra-example-driver/internal/profiles/cpu"
)

var (
testShareId = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
)

func TestPreparedDevicesGetDevices(t *testing.T) {
tests := map[string]struct {
preparedDevices PreparedDevices
Expand All @@ -55,6 +59,16 @@ func TestPreparedDevicesGetDevices(t *testing.T) {
{DeviceName: "dev3"},
},
},
"preparedDevice with shareId": {
preparedDevices: PreparedDevices{
{Device: drapbv1.Device{DeviceName: "dev1", ShareId: &testShareId}},
{Device: drapbv1.Device{DeviceName: "dev2", ShareId: &testShareId}},
},
expected: []*drapbv1.Device{
{DeviceName: "dev1", ShareId: &testShareId},
{DeviceName: "dev2", ShareId: &testShareId},
},
},
}

for name, test := range tests {
Expand Down
5 changes: 4 additions & 1 deletion internal/profiles/gpu/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package gpu

import (
"context"
"encoding/json"
"fmt"
"maps"
Expand Down Expand Up @@ -316,6 +317,8 @@ func (p Profile) BuildDeviceStatus(allocatable map[string]resourceapi.Device, re
if !p.enableDeviceStatus {
return nil
}
ctx := context.Background()
logger := klog.FromContext(ctx).WithValues("device", result.Device)

deviceInfo := make(map[string]resourceapi.DeviceAttribute)
if d, ok := allocatable[result.Device]; ok {
Expand All @@ -328,7 +331,7 @@ func (p Profile) BuildDeviceStatus(allocatable map[string]resourceapi.Device, re

jsonBytes, err := json.Marshal(deviceInfo)
if err != nil {
klog.Errorf("Failed to marshal device data for %s: %v", result.Device, err)
logger.Error(err, "Failed to marshal device data")
jsonBytes = []byte("{}")
}

Expand Down
Loading