Skip to content

Commit

Permalink
koord-manager: get node batch allocatable from extended resource (#1752)
Browse files Browse the repository at this point in the history
Signed-off-by: 佑祎 <[email protected]>
  • Loading branch information
zwzhang0107 authored Nov 22, 2023
1 parent 3784df1 commit cf2b50f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ func (p *Plugin) Prepare(_ *configuration.ColocationStrategy, node *corev1.Node,
}

// set origin batch allocatable
batchMilliCPU := util.GetBatchMilliCPUFromResourceList(node.Status.Allocatable)
batchMemory := util.GetBatchMemoryFromResourceList(node.Status.Allocatable)
batchMilliCPU := util.GetNodeAllocatableBatchMilliCPU(node)
//batchMilliCPU := util.GetBatchMilliCPUFromResourceList(node.Status.Allocatable)
batchMemory := util.GetNodeAllocatableBatchMemory(node)
originBatchAllocatable := corev1.ResourceList{
extension.BatchCPU: *resource.NewQuantity(util.MaxInt64(batchMilliCPU, 0), resource.DecimalSI),
extension.BatchMemory: *resource.NewQuantity(util.MaxInt64(batchMemory, 0), resource.BinarySI),
Expand Down
16 changes: 16 additions & 0 deletions pkg/util/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,19 @@ func GetNodeAnnoReservedJson(reserved apiext.NodeReservation) string {

return result
}

func GetNodeAllocatableBatchMilliCPU(node *corev1.Node) int64 {
// assert node != nil
if milliCPU, ok := node.Status.Allocatable[apiext.BatchCPU]; ok {
return milliCPU.Value()
}
return -1
}

func GetNodeAllocatableBatchMemory(node *corev1.Node) int64 {
// assert node != nil
if memory, ok := node.Status.Allocatable[apiext.BatchMemory]; ok {
return memory.Value()
}
return -1
}

0 comments on commit cf2b50f

Please sign in to comment.