Skip to content

Commit

Permalink
Merge pull request #193 from klueska/fix-cdi-bug
Browse files Browse the repository at this point in the history
Fix regression with managing claim-specific CDI devices
  • Loading branch information
klueska authored Oct 28, 2024
2 parents c3bdccc + ab96031 commit a3a469b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cmd/nvidia-dra-plugin/cdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()))
}
2 changes: 1 addition & 1 deletion cmd/nvidia-dra-plugin/device_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit a3a469b

Please sign in to comment.