Skip to content
6 changes: 5 additions & 1 deletion pkg/device/amd/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@ func (amddevice *AMDDevices) Fit(devices []*device.DeviceUsage, request device.C
for i, v := range slices.Backward(devices) {
dev := v
klog.V(4).InfoS("scoring pod", "pod", klog.KObj(pod), "device", dev.ID, "Memreq", k.Memreq, "MemPercentagereq", k.MemPercentagereq, "Coresreq", k.Coresreq, "Nums", k.Nums, "device index", i)

if !dev.Health {
Comment thread
Shouren marked this conversation as resolved.
reason[common.CardNotHealth]++
klog.V(5).InfoS(common.CardNotHealth, "pod", klog.KObj(pod), "device", dev.ID, "health", dev.Health)
continue
}
klog.V(3).InfoS("Type check", "device", dev.Type, "req", k.Type, "dev=", dev)
_, found, _ := amddevice.checkType(pod.GetAnnotations(), *dev, k)
if !found {
Expand Down
16 changes: 16 additions & 0 deletions pkg/device/amd/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,20 @@ func TestDevices_Fit(t *testing.T) {
assert.Equal(t, false, ok)
assert.Assert(t, strings.Contains(reason, common.CardTimeSlicingExhausted))
})

t.Run("unhealthy device is rejected", func(t *testing.T) {
devices := []*device.DeviceUsage{
{
ID: "dev-0", Index: 0, Used: 0, Count: 2,
Usedmem: 0, Totalmem: 1000, Totalcore: 100, Usedcores: 0,
Type: AMDDevice, Health: false, CustomInfo: map[string]any{},
},
}
req := device.ContainerDeviceRequest{Nums: 1, Type: AMDDevice, Memreq: 100, MemPercentagereq: 0, Coresreq: 10}
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Annotations: map[string]string{}}}

ok, _, reason := dev.Fit(devices, req, pod, &device.NodeInfo{}, &device.PodDevices{})
assert.Equal(t, false, ok)
assert.Assert(t, strings.Contains(reason, common.CardNotHealth))
})
}
8 changes: 6 additions & 2 deletions pkg/device/awsneuron/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func continuousDeviceAvailable(devices []*device.DeviceUsage, start int, count i
res := []int{}
iterator := start
for iterator < start+count {
if devices[iterator].Used > 0 {
if devices[iterator].Used > 0 || !devices[iterator].Health {
return []int{}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
res = append(res, iterator)
Expand Down Expand Up @@ -398,7 +398,11 @@ func (neuron *AWSNeuronDevices) Fit(devices []*device.DeviceUsage, request devic
dev.CustomInfo[AWSUsageInfo] = int(dev.Usedcores)
}
klog.V(4).InfoS("scoring pod", "pod", klog.KObj(pod), "device", dev.ID, "Memreq", k.Memreq, "MemPercentagereq", k.MemPercentagereq, "Coresreq", k.Coresreq, "Nums", k.Nums, "device index", i)

if !dev.Health {
reason[common.CardNotHealth]++
klog.V(5).InfoS(common.CardNotHealth, "pod", klog.KObj(pod), "device", dev.ID, "health", dev.Health)
continue
}
klog.V(3).InfoS("Type check", "device", dev.Type, "req", k.Type, "dev=", dev)
if !strings.Contains(dev.Type, k.Type) {
reason[common.CardTypeMismatch]++
Expand Down
Loading
Loading