@@ -49,30 +49,30 @@ const (
4949
5050// NodeInfo is node level aggregated information.
5151type NodeInfo struct {
52- Name string `json:"name,omitempty"`
53- Node * v1.Node `json:"node,omitempty"`
52+ Name string
53+ Node * v1.Node
5454
5555 // The releasing resource on that node (excluding shared GPUs)
56- Releasing * resource_info.Resource `json:"releasing,omitempty"`
56+ Releasing * resource_info.Resource
5757 // The idle resource on that node (excluding shared GPUs)
58- Idle * resource_info.Resource `json:"idle,omitempty"`
58+ Idle * resource_info.Resource
5959 // The used resource on that node, including running and terminating
6060 // pods (excluding shared GPUs)
61- Used * resource_info.Resource `json:"used,omitempty"`
61+ Used * resource_info.Resource
6262
63- Allocatable * resource_info.Resource `json:"allocatable,omitempty"`
63+ Allocatable * resource_info.Resource
6464
65- AccessibleStorageCapacities map [common_info.StorageClassID ][]* sc_info.StorageCapacityInfo `json:"accessibleStorageCapacities,omitempty"`
65+ AccessibleStorageCapacities map [common_info.StorageClassID ][]* sc_info.StorageCapacityInfo
6666
67- PodInfos map [common_info.PodID ]* pod_info.PodInfo `json:"podInfos,omitempty"`
68- MaxTaskNum int `json:"maxTaskNum,omitempty"`
69- MemoryOfEveryGpuOnNode int64 `json:"memoryOfEveryGpuOnNode,omitempty"`
70- GpuMemorySynced bool `json:"gpuMemorySynced,omitempty"`
71- LegacyMIGTasks map [common_info.PodID ]string `json:"legacyMigTasks,omitempty"`
67+ PodInfos map [common_info.PodID ]* pod_info.PodInfo
68+ MaxTaskNum int
69+ MemoryOfEveryGpuOnNode int64
70+ GpuMemorySynced bool
71+ LegacyMIGTasks map [common_info.PodID ]string
7272
73- PodAffinityInfo pod_affinity.NodePodAffinityInfo `json:"podAffinityInfo,omitempty"`
73+ PodAffinityInfo pod_affinity.NodePodAffinityInfo
7474
75- GpuSharingNodeInfo `json:"gpuSharingNodeInfo,omitempty"`
75+ GpuSharingNodeInfo
7676}
7777
7878func NewNodeInfo (node * v1.Node , podAffinityInfo pod_affinity.NodePodAffinityInfo ) * NodeInfo {
@@ -103,7 +103,7 @@ func NewNodeInfo(node *v1.Node, podAffinityInfo pod_affinity.NodePodAffinityInfo
103103 nodeInfo .MaxTaskNum = int (numTasks .Value ())
104104
105105 capacity := resource_info .ResourceFromResourceList (node .Status .Capacity )
106- if capacity .GPUs != nodeInfo .Allocatable .GPUs {
106+ if capacity .GPUs () != nodeInfo .Allocatable .GPUs () {
107107 log .InfraLogger .V (2 ).Warnf (
108108 "For node %s, the capacity and allocatable are different. Capacity %v, Allocatable %v" ,
109109 node .Name , capacity .DetailedString (), nodeInfo .Allocatable .DetailedString ())
@@ -307,7 +307,7 @@ func (ni *NodeInfo) isTaskAllocatableOnNonAllocatedResources(
307307 if ! ni .isValidGpuPortion (task .ResReq ) {
308308 return false
309309 }
310- nodeIdleOrReleasingWholeGpus := int64 (math .Floor (nodeNonAllocatedResources .GPUs ))
310+ nodeIdleOrReleasingWholeGpus := int64 (math .Floor (nodeNonAllocatedResources .GPUs () ))
311311 nodeNonAllocatedResourcesMatchingSharedGpus := ni .fractionTaskGpusAllocatableDeviceCount (task )
312312 if nodeIdleOrReleasingWholeGpus + nodeNonAllocatedResourcesMatchingSharedGpus >= task .ResReq .GetNumOfGpuDevices () {
313313 return true
@@ -515,9 +515,9 @@ func (ni *NodeInfo) String() string {
515515
516516func (ni * NodeInfo ) GetSumOfIdleGPUs () (float64 , int64 ) {
517517 sumOfSharedGPUs , sumOfSharedGPUsMemory := ni .getSumOfAvailableSharedGPUs ()
518- idleGPUs := ni .Idle .GPUs
518+ idleGPUs := ni .Idle .GPUs ()
519519
520- for resourceName , qty := range ni .Idle .ScalarResources {
520+ for resourceName , qty := range ni .Idle .ScalarResources () {
521521 if ! isMigResource (resourceName .String ()) {
522522 continue
523523 }
@@ -534,9 +534,9 @@ func (ni *NodeInfo) GetSumOfIdleGPUs() (float64, int64) {
534534
535535func (ni * NodeInfo ) GetSumOfReleasingGPUs () (float64 , int64 ) {
536536 sumOfSharedGPUs , sumOfSharedGPUsMemory := ni .getSumOfReleasingSharedGPUs ()
537- releasingGPUs := ni .Releasing .GPUs
537+ releasingGPUs := ni .Releasing .GPUs ()
538538
539- for resourceName , qty := range ni .Releasing .ScalarResources {
539+ for resourceName , qty := range ni .Releasing .ScalarResources () {
540540 if ! isMigResource (resourceName .String ()) {
541541 continue
542542 }
@@ -569,7 +569,7 @@ func (ni *NodeInfo) GetNumberOfGPUsInNode() int64 {
569569 numberOfGPUs , err := ni .getNodeGpuCountLabelValue ()
570570 if err != nil {
571571 log .InfraLogger .V (6 ).Infof ("Node: <%v> had no annotations of nvidia.com/gpu.count" , ni .Name )
572- return int64 (ni .Allocatable .GPUs )
572+ return int64 (ni .Allocatable .GPUs () )
573573 }
574574 return int64 (numberOfGPUs )
575575}
@@ -629,7 +629,7 @@ func (ni *NodeInfo) IsCPUOnlyNode() bool {
629629 if ni .IsMIGEnabled () {
630630 return false
631631 }
632- return ni .Allocatable .GPUs == 0
632+ return ni .Allocatable .GPUs () == 0
633633}
634634
635635func (ni * NodeInfo ) IsMIGEnabled () bool {
@@ -638,7 +638,7 @@ func (ni *NodeInfo) IsMIGEnabled() bool {
638638 isMig , err := strconv .ParseBool (enabled )
639639 return err == nil && isMig
640640 }
641- for nodeResource := range ni .Allocatable .ScalarResources {
641+ for nodeResource := range ni .Allocatable .ScalarResources () {
642642 if isMigResource (nodeResource .String ()) {
643643 return true
644644 }
@@ -663,13 +663,13 @@ func (ni *NodeInfo) GetMigStrategy() MigStrategy {
663663
664664func (ni * NodeInfo ) GetRequiredInitQuota (pi * pod_info.PodInfo ) * podgroup_info.JobRequirement {
665665 quota := podgroup_info.JobRequirement {}
666- if len (pi .ResReq .MIGResources ) != 0 {
666+ if len (pi .ResReq .MigResources () ) != 0 {
667667 quota .GPU = pi .ResReq .GetSumGPUs ()
668668 } else {
669669 quota .GPU = ni .getGpuMemoryFractionalOnNode (ni .GetResourceGpuMemory (pi .ResReq ))
670670 }
671- quota .MilliCPU = pi .ResReq .CPUMilliCores
672- quota .Memory = pi .ResReq .MemoryBytes
671+ quota .MilliCPU = pi .ResReq .Cpu ()
672+ quota .Memory = pi .ResReq .Memory ()
673673 return & quota
674674}
675675
@@ -682,7 +682,7 @@ func (ni *NodeInfo) setAcceptedResources(pi *pod_info.PodInfo) {
682682 if pi .IsMigCandidate () {
683683 pi .ResourceReceivedType = pod_info .ReceivedTypeMigInstance
684684 pi .AcceptedResource .GpuResourceRequirement =
685- * resource_info .NewGpuResourceRequirementWithMig (pi .ResReq .MIGResources )
685+ * resource_info .NewGpuResourceRequirementWithMig (pi .ResReq .MigResources () )
686686 } else if pi .IsFractionCandidate () {
687687 pi .ResourceReceivedType = pod_info .ReceivedTypeFraction
688688 pi .AcceptedResource .GpuResourceRequirement = * resource_info .NewGpuResourceRequirementWithMultiFraction (
0 commit comments