Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions cmd/gpu-kubelet-plugin/allocatable.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ func (d *AllocatableDevice) CanonicalName() string {
panic("unexpected type for AllocatableDevice")
}

func (d *AllocatableDevice) CanonicalIndex() string {
func (d *AllocatableDevice) GetDevice() resourceapi.Device {
switch d.Type() {
case GpuDeviceType:
return d.Gpu.CanonicalIndex()
return d.Gpu.GetDevice()
case MigDeviceType:
return d.Mig.CanonicalIndex()
return d.Mig.GetDevice()
}
panic("unexpected type for AllocatableDevice")
}

func (d *AllocatableDevice) GetDevice() resourceapi.Device {
switch d.Type() {
case GpuDeviceType:
return d.Gpu.GetDevice()
case MigDeviceType:
return d.Mig.GetDevice()
func (d AllocatableDevice) UUID() string {
if d.Gpu != nil {
return d.Gpu.UUID
}
if d.Mig != nil {
return d.Mig.UUID
}
panic("unexpected type for AllocatableDevice")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gpu-kubelet-plugin/cdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (cdi *CDIHandler) CreateStandardDeviceSpecFile(allocatable AllocatableDevic
// Generate device specs for all full GPUs and MIG devices.
var deviceSpecs []cdispec.Device
for _, device := range allocatable {
dspecs, err := cdi.nvcdiDevice.GetDeviceSpecsByID(device.CanonicalIndex())
dspecs, err := cdi.nvcdiDevice.GetDeviceSpecsByID(device.UUID())
if err != nil {
return fmt.Errorf("unable to get device spec for %s: %w", device.CanonicalName(), err)
}
Expand Down
19 changes: 0 additions & 19 deletions cmd/gpu-kubelet-plugin/deviceinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

type GpuInfo struct {
UUID string `json:"uuid"`
index int
minor int
migEnabled bool
memoryBytes uint64
Expand All @@ -47,7 +46,6 @@ type GpuInfo struct {

type MigDeviceInfo struct {
UUID string `json:"uuid"`
index int
profile string
parent *GpuInfo
placement *MigDevicePlacement
Expand Down Expand Up @@ -80,14 +78,6 @@ func (d *MigDeviceInfo) CanonicalName() string {
return fmt.Sprintf("gpu-%d-mig-%d-%d-%d", d.parent.minor, d.giInfo.ProfileId, d.placement.Start, d.placement.Size)
}

func (d *GpuInfo) CanonicalIndex() string {
return fmt.Sprintf("%d", d.index)
}

func (d *MigDeviceInfo) CanonicalIndex() string {
return fmt.Sprintf("%d:%d", d.parent.index, d.index)
}

func (d *GpuInfo) GetDevice() resourceapi.Device {
device := resourceapi.Device{
Name: d.CanonicalName(),
Expand All @@ -101,9 +91,6 @@ func (d *GpuInfo) GetDevice() resourceapi.Device {
"minor": {
IntValue: ptr.To(int64(d.minor)),
},
"index": {
IntValue: ptr.To(int64(d.index)),
},
"productName": {
StringValue: &d.productName,
},
Expand Down Expand Up @@ -151,12 +138,6 @@ func (d *MigDeviceInfo) GetDevice() resourceapi.Device {
"parentUUID": {
StringValue: &d.parent.UUID,
},
"index": {
IntValue: ptr.To(int64(d.index)),
},
"parentIndex": {
IntValue: ptr.To(int64(d.parent.index)),
},
"profile": {
StringValue: &d.profile,
},
Expand Down
2 changes: 0 additions & 2 deletions cmd/gpu-kubelet-plugin/nvlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ func (l deviceLib) getGpuInfo(index int, device nvdev.Device) (*GpuInfo, error)
gpuInfo := &GpuInfo{
UUID: uuid,
minor: minor,
index: index,
migEnabled: migEnabled,
memoryBytes: memory.Total,
productName: productName,
Expand Down Expand Up @@ -360,7 +359,6 @@ func (l deviceLib) getMigDevices(gpuInfo *GpuInfo) (map[string]*MigDeviceInfo, e

migInfos[uuid] = &MigDeviceInfo{
UUID: uuid,
index: i,
profile: migProfile.String(),
parent: gpuInfo,
placement: &placement,
Expand Down
10 changes: 0 additions & 10 deletions cmd/gpu-kubelet-plugin/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ func (d *PreparedDevice) CanonicalName() string {
panic("unexpected type for AllocatableDevice")
}

func (d *PreparedDevice) CanonicalIndex() string {
switch d.Type() {
case GpuDeviceType:
return d.Gpu.Info.CanonicalIndex()
case MigDeviceType:
return d.Mig.Info.CanonicalIndex()
}
panic("unexpected type for AllocatableDevice")
}

func (l PreparedDeviceList) Gpus() PreparedDeviceList {
var devices PreparedDeviceList
for _, device := range l {
Expand Down