@@ -104,9 +104,14 @@ func (n *NodeResourceInfo) RemoveEmptyCores() {
104104}
105105
106106func (n * NodeResourceInfo ) Validate () error {
107- if n .Capacity == nil || len ( n . Capacity . CPUMap ) == 0 {
107+ if n .Capacity == nil {
108108 return ErrInvalidCapacity
109109 }
110+
111+ if len (n .Capacity .CPUMap ) == 0 {
112+ return ErrInvalidCPUMap
113+ }
114+
110115 if n .Usage == nil {
111116 n .Usage = & NodeResource {
112117 CPU : 0 ,
@@ -125,12 +130,9 @@ func (n *NodeResourceInfo) Validate() error {
125130 n .Usage .NUMA [cpuID ] = numaNodeID
126131 }
127132 }
128- if len (n .Capacity .CPUMap ) == 0 {
129- return ErrInvalidCPUMap
130- }
131133
132134 for cpu , piecesUsed := range n .Usage .CPUMap {
133- if totalPieces , ok := n .Capacity .CPUMap [cpu ]; ! ok || piecesUsed < 0 || totalPieces < 0 || piecesUsed > totalPieces {
135+ if totalPieces , ok := n .Capacity .CPUMap [cpu ]; ! ok || totalPieces < 0 || piecesUsed > totalPieces {
134136 return ErrInvalidCPUMap
135137 }
136138 }
@@ -221,9 +223,9 @@ func (n *NodeResourceRequest) Parse(config coretypes.Config, rawParams resourcet
221223 }
222224 }
223225
224- for index , numaMemoryNode := range rawParams .StringSlice ("numa-memory" ) {
226+ for index , nodeMemory := range rawParams .StringSlice ("numa-memory" ) {
225227 nodeID := fmt .Sprintf ("%d" , index )
226- mem , err := coreutils .ParseRAMInHuman (numaMemoryNode )
228+ mem , err := coreutils .ParseRAMInHuman (nodeMemory )
227229 if err != nil {
228230 return err
229231 }
@@ -233,20 +235,20 @@ func (n *NodeResourceRequest) Parse(config coretypes.Config, rawParams resourcet
233235 return nil
234236}
235237
236- func (n * NodeResourceRequest ) LoadFromOrigin (nodeResource * NodeResource , rawParams resourcetypes.RawParams ) {
238+ func (n * NodeResourceRequest ) LoadFromOrigin (nodeResource * NodeResource , resourceRequest resourcetypes.RawParams ) {
237239 if n == nil {
238240 return
239241 }
240- if ! rawParams .IsSet ("cpu" ) {
242+ if ! resourceRequest .IsSet ("cpu" ) {
241243 n .CPUMap = nodeResource .CPUMap
242244 }
243- if ! rawParams .IsSet ("memory" ) {
245+ if ! resourceRequest .IsSet ("memory" ) {
244246 n .Memory = nodeResource .Memory
245247 }
246- if ! rawParams .IsSet ("numa-cpu" ) {
248+ if ! resourceRequest .IsSet ("numa-cpu" ) {
247249 n .NUMA = nodeResource .NUMA
248250 }
249- if ! rawParams .IsSet ("numa-memory" ) {
251+ if ! resourceRequest .IsSet ("numa-memory" ) {
250252 n .NUMAMemory = nodeResource .NUMAMemory
251253 }
252254}
0 commit comments