Skip to content

Commit

Permalink
scheduler: fix a bug where we subtract reserved node resources twice (#…
Browse files Browse the repository at this point in the history
…23386)

Fixes a bug in the nodeResources.Comparable method, where CPU resources were
accidentally offset with reserved resources, whereas functions that use this
field expect total CPU resources.
  • Loading branch information
pkazmierczak authored Jun 21, 2024
1 parent c84b4ad commit 8f80bd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/23386.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
scheduler: Fix a bug where reserved resources are not calculated correctly
```
1 change: 1 addition & 0 deletions nomad/structs/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func node2k() *Node {
Grade: numalib.Performance,
BaseSpeed: 1000,
}},
OverrideWitholdCompute: 1000, // set by client reserved field
},
},
Memory: NodeMemoryResources{
Expand Down
2 changes: 1 addition & 1 deletion nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ func (n *NodeResources) Comparable() *ComparableResources {
c := &ComparableResources{
Flattened: AllocatedTaskResources{
Cpu: AllocatedCpuResources{
CpuShares: int64(n.Processors.Topology.UsableCompute()),
CpuShares: int64(n.Processors.Topology.TotalCompute()),
ReservedCores: reservableCores,
},
Memory: AllocatedMemoryResources{
Expand Down

0 comments on commit 8f80bd5

Please sign in to comment.