@@ -104,9 +104,14 @@ func (n *NodeResourceInfo) RemoveEmptyCores() {
104
104
}
105
105
106
106
func (n * NodeResourceInfo ) Validate () error {
107
- if n .Capacity == nil || len ( n . Capacity . CPUMap ) == 0 {
107
+ if n .Capacity == nil {
108
108
return ErrInvalidCapacity
109
109
}
110
+
111
+ if len (n .Capacity .CPUMap ) == 0 {
112
+ return ErrInvalidCPUMap
113
+ }
114
+
110
115
if n .Usage == nil {
111
116
n .Usage = & NodeResource {
112
117
CPU : 0 ,
@@ -125,12 +130,9 @@ func (n *NodeResourceInfo) Validate() error {
125
130
n .Usage .NUMA [cpuID ] = numaNodeID
126
131
}
127
132
}
128
- if len (n .Capacity .CPUMap ) == 0 {
129
- return ErrInvalidCPUMap
130
- }
131
133
132
134
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 {
134
136
return ErrInvalidCPUMap
135
137
}
136
138
}
@@ -221,9 +223,9 @@ func (n *NodeResourceRequest) Parse(config coretypes.Config, rawParams resourcet
221
223
}
222
224
}
223
225
224
- for index , numaMemoryNode := range rawParams .StringSlice ("numa-memory" ) {
226
+ for index , nodeMemory := range rawParams .StringSlice ("numa-memory" ) {
225
227
nodeID := fmt .Sprintf ("%d" , index )
226
- mem , err := coreutils .ParseRAMInHuman (numaMemoryNode )
228
+ mem , err := coreutils .ParseRAMInHuman (nodeMemory )
227
229
if err != nil {
228
230
return err
229
231
}
@@ -233,20 +235,20 @@ func (n *NodeResourceRequest) Parse(config coretypes.Config, rawParams resourcet
233
235
return nil
234
236
}
235
237
236
- func (n * NodeResourceRequest ) LoadFromOrigin (nodeResource * NodeResource , rawParams resourcetypes.RawParams ) {
238
+ func (n * NodeResourceRequest ) LoadFromOrigin (nodeResource * NodeResource , resourceRequest resourcetypes.RawParams ) {
237
239
if n == nil {
238
240
return
239
241
}
240
- if ! rawParams .IsSet ("cpu" ) {
242
+ if ! resourceRequest .IsSet ("cpu" ) {
241
243
n .CPUMap = nodeResource .CPUMap
242
244
}
243
- if ! rawParams .IsSet ("memory" ) {
245
+ if ! resourceRequest .IsSet ("memory" ) {
244
246
n .Memory = nodeResource .Memory
245
247
}
246
- if ! rawParams .IsSet ("numa-cpu" ) {
248
+ if ! resourceRequest .IsSet ("numa-cpu" ) {
247
249
n .NUMA = nodeResource .NUMA
248
250
}
249
- if ! rawParams .IsSet ("numa-memory" ) {
251
+ if ! resourceRequest .IsSet ("numa-memory" ) {
250
252
n .NUMAMemory = nodeResource .NUMAMemory
251
253
}
252
254
}
0 commit comments