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
14 changes: 8 additions & 6 deletions pkg/device/ascend/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,16 @@ func (npu *Devices) Fit(devices []*device.DeviceUsage, request device.ContainerD
totalMemPerCard = devices[0].Totalmem
}

if isHAMiCore && !nodeSupportHamiCore {
reason[common.ModeNotFit]++
klog.V(4).InfoS("Node filtered: pod requests hami-core but node does not support it", "pod", klog.KObj(pod))
return false, nil, common.GenReason(reason, len(devices))
}

if request.Memreq > 0 && request.Memreq < totalMemPerCard && request.Nums > 0 {
if !nodeSupportHamiCore && isHAMiCore {
reason[common.ModeNotFit]++
klog.V(4).InfoS("Node filtered: Node does not support hami-core mode", "node", nodeInfo.Node.Name, "pod", pod.Name)
return false, nil, common.GenReason(reason, len(devices))
} else if nodeSupportHamiCore && !isHAMiCore {
if nodeSupportHamiCore && !isHAMiCore {
reason[common.ModeNotFit]++
klog.V(4).InfoS("Node filtered: Reserved for hami-core but pod is legacy vNPU", "node", nodeInfo.Node.Name, "pod", pod.Name)
klog.V(4).InfoS("Node filtered: node reserved for hami-core but pod is legacy vNPU", "pod", klog.KObj(pod))
return false, nil, common.GenReason(reason, len(devices))
Comment thread
Wangmin362 marked this conversation as resolved.
}
}
Expand Down
74 changes: 74 additions & 0 deletions pkg/device/ascend/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,80 @@ func TestDevices_Fit(t *testing.T) {
wantReason: "1/1 ModeNotFit",
nodeAnnotation: map[string]string{VNPUNodeSelectorAnnotation: "true"},
},
{
name: "fit fail: whole-card hami-core pod on legacy node (ModeNotFit)",
devices: []*device.DeviceUsage{{
ID: "dev-0", Index: 0, Used: 0, Count: 100,
Usedmem: 0, Totalmem: 32768, Totalcore: 100, Usedcores: 0,
Numa: 0, Health: true,
}},
request: device.ContainerDeviceRequest{
Nums: 1, Memreq: 32768, MemPercentagereq: 0, Coresreq: 0,
},
annos: map[string]string{
VNPUModeAnnotation: VNPUModeHamiCore,
},
wantFit: false,
wantLen: 0,
wantDevIDs: []string{},
wantReason: "1/1 ModeNotFit",
nodeAnnotation: map[string]string{},
},
{
name: "fit fail: memory-less hami-core pod on legacy node (ModeNotFit)",
devices: []*device.DeviceUsage{{
ID: "dev-0", Index: 0, Used: 0, Count: 100,
Usedmem: 0, Totalmem: 32768, Totalcore: 100, Usedcores: 0,
Numa: 0, Health: true,
}},
request: device.ContainerDeviceRequest{
Nums: 1, Memreq: 0, MemPercentagereq: 101, Coresreq: 0,
},
annos: map[string]string{
VNPUModeAnnotation: VNPUModeHamiCore,
},
wantFit: false,
wantLen: 0,
wantDevIDs: []string{},
wantReason: "1/1 ModeNotFit",
nodeAnnotation: map[string]string{},
},
{
name: "fit success: whole-card hami-core pod on hami-core node",
devices: []*device.DeviceUsage{{
ID: "dev-0", Index: 0, Used: 0, Count: 100,
Usedmem: 0, Totalmem: 32768, Totalcore: 100, Usedcores: 0,
Numa: 0, Health: true,
}},
request: device.ContainerDeviceRequest{
Nums: 1, Memreq: 32768, MemPercentagereq: 0, Coresreq: 0,
},
annos: map[string]string{
VNPUModeAnnotation: VNPUModeHamiCore,
},
wantFit: true,
wantLen: 1,
wantDevIDs: []string{"dev-0"},
wantReason: "",
nodeAnnotation: map[string]string{VNPUNodeSelectorAnnotation: "true"},
},
{
name: "fit success: whole-card legacy pod on hami-core node",
devices: []*device.DeviceUsage{{
ID: "dev-0", Index: 0, Used: 0, Count: 100,
Usedmem: 0, Totalmem: 32768, Totalcore: 100, Usedcores: 0,
Numa: 0, Health: true,
}},
request: device.ContainerDeviceRequest{
Nums: 1, Memreq: 32768, MemPercentagereq: 0, Coresreq: 0,
},
annos: map[string]string{},
wantFit: true,
wantLen: 1,
wantDevIDs: []string{"dev-0"},
wantReason: "",
nodeAnnotation: map[string]string{VNPUNodeSelectorAnnotation: "true"},
},
}

for _, dev := range devs {
Expand Down
Loading