plugins: fix nomadTopologyToProto panic on systems that don't support NUMA (#23399)

After changes introduced in #23284 we no longer need to make a if
!st.SupportsNUMA() check in the GetNodes() topology method. In fact this check
will now cause panic in nomadTopologyToProto method on systems that don't
support NUMA.
This commit is contained in:
Piotr Kazmierczak
2024-07-09 08:41:52 +02:00
committed by GitHub
parent 6560a0ce02
commit 7772711c89
4 changed files with 18 additions and 4 deletions

3
.changelog/23399.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
plugins: Fix panic on systems that don't support NUMA
```

View File

@@ -89,7 +89,8 @@ jobs:
github.com/hashicorp/nomad/drivers/docker \
github.com/hashicorp/nomad/client/lib/fifo \
github.com/hashicorp/nomad/client/logmon \
github.com/hashicorp/nomad/client/allocrunner/taskrunner/template
github.com/hashicorp/nomad/client/allocrunner/taskrunner/template \
github.com/hashicorp/nomad/plugins/base
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: results.xml

View File

@@ -164,9 +164,6 @@ func (st *Topology) SupportsNUMA() bool {
// GetNodes returns the set of NUMA Node IDs.
func (st *Topology) GetNodes() *idset.Set[hw.NodeID] {
if !st.SupportsNUMA() {
return nil
}
if st.nodeIDs.Empty() {
st.nodeIDs = idset.From[hw.NodeID](st.Nodes)
}

View File

@@ -55,6 +55,19 @@ func Test_nomadTopologyToProto(t *testing.T) {
OverrideTotalCompute: 90_000,
OverrideWitholdCompute: 2000,
}, pb)
// make sure we don't panic in case of empty nodes, vide
// https://github.com/hashicorp/nomad/issues/23385
top2 := &numalib.Topology{}
pb2 := nomadTopologyToProto(top2)
must.Eq(t, &proto.ClientTopology{
NodeIds: []uint32{},
Distances: &proto.ClientTopologySLIT{Dimension: 0, Values: []uint32{}},
Cores: nil,
OverrideTotalCompute: 0,
OverrideWitholdCompute: 0,
}, pb2)
}
func Test_nomadTopologyFromProto(t *testing.T) {