Skip to content

Commit

Permalink
scheduler: revise device allocate logic (#1927)
Browse files Browse the repository at this point in the history
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
ZiMengSheng and wangjianyu.wjy committed Mar 5, 2024
1 parent 03f89eb commit 987c076
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/deviceshare/device_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (a *AutopilotAllocator) allocateByTopology(requestCtx *requestContext, node
for _, pcie := range freeNodeDevicesInPCIe {
if len(pcie.freeDevices[primaryDeviceType]) >= desiredCount {
allocations, status := a.jointAllocate(pcie.nodeDevice, requestCtx, jointAllocate, primaryDeviceType, secondaryDeviceTypes, sets.NewString(pcie.PCIeIndex.pcie))
if status.IsSuccess() {
if status.IsSuccess() && len(allocations) > 0 {
return allocations, nil
}
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/scheduler/plugins/deviceshare/device_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ func (n *nodeDevice) filter(
for minor, free := range freeDevices {
if minors.Has(minor) {
totalByDeviceType[minor] = originalTotal[minor].DeepCopy()
usedByDeviceType[minor] = quotav1.SubtractWithNonNegativeResult(originalTotal[minor], free)
usedByDeviceTypeOfMinor := quotav1.SubtractWithNonNegativeResult(originalTotal[minor], free)
if !quotav1.IsZero(usedByDeviceTypeOfMinor) {
usedByDeviceType[minor] = usedByDeviceTypeOfMinor
}

}
}

Expand Down

0 comments on commit 987c076

Please sign in to comment.