From ab960316ae3262908b9df9118c70a0dfbb90c0d2 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Mon, 28 Oct 2024 18:30:36 +0000 Subject: [PATCH] Fix regression with managing claim-specific CDI devices Signed-off-by: Kevin Klues --- cmd/nvidia-dra-plugin/cdi.go | 7 +++++-- cmd/nvidia-dra-plugin/device_state.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/nvidia-dra-plugin/cdi.go b/cmd/nvidia-dra-plugin/cdi.go index e76fc181..548f624d 100644 --- a/cmd/nvidia-dra-plugin/cdi.go +++ b/cmd/nvidia-dra-plugin/cdi.go @@ -230,7 +230,7 @@ func (cdi *CDIHandler) CreateClaimSpecFile(claimUID string, preparedDevices Prep // Generate claim specific specs for each device. var deviceSpecs []cdispec.Device for _, group := range preparedDevices { - // If there are no edits passed back as prt of the device config state, skip it + // If there are no edits passed back as part of the device config state, skip it if group.ConfigState.containerEdits == nil { continue } @@ -290,6 +290,9 @@ func (cdi *CDIHandler) GetStandardDevice(device *AllocatableDevice) string { return cdiparser.QualifiedName(cdiVendor, cdiDeviceClass, device.CanonicalName()) } -func (cdi *CDIHandler) GetClaimDevice(claimUID string, device *AllocatableDevice) string { +func (cdi *CDIHandler) GetClaimDevice(claimUID string, device *AllocatableDevice, containerEdits *cdiapi.ContainerEdits) string { + if containerEdits == nil { + return "" + } return cdiparser.QualifiedName(cdiVendor, cdiClaimClass, fmt.Sprintf("%s-%s", claimUID, device.CanonicalName())) } diff --git a/cmd/nvidia-dra-plugin/device_state.go b/cmd/nvidia-dra-plugin/device_state.go index 33499e9c..0ecd3423 100644 --- a/cmd/nvidia-dra-plugin/device_state.go +++ b/cmd/nvidia-dra-plugin/device_state.go @@ -309,7 +309,7 @@ func (s *DeviceState) prepareDevices(ctx context.Context, claim *resourceapi.Res if d := s.cdi.GetStandardDevice(s.allocatable[result.Device]); d != "" { cdiDevices = append(cdiDevices, d) } - if d := s.cdi.GetClaimDevice(string(claim.UID), s.allocatable[result.Device]); d != "" { + if d := s.cdi.GetClaimDevice(string(claim.UID), s.allocatable[result.Device], preparedDeviceGroupConfigState[c].containerEdits); d != "" { cdiDevices = append(cdiDevices, d) }