Skip to content

Commit 8cec42e

Browse files
backport of commit 3b44090 (#26221)
Co-authored-by: Juana De La Cuesta <[email protected]>
1 parent e7cf8ca commit 8cec42e

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

client/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,12 @@ func (c *Client) setupNode() error {
15691569
node.NodeResources.MinDynamicPort = newConfig.MinDynamicPort
15701570
node.NodeResources.MaxDynamicPort = newConfig.MaxDynamicPort
15711571
node.NodeResources.Processors = newConfig.Node.NodeResources.Processors
1572+
1573+
if node.NodeResources.Processors.Empty() {
1574+
node.NodeResources.Processors = structs.NodeProcessorResources{
1575+
Topology: &numalib.Topology{},
1576+
}
1577+
}
15721578
}
15731579
if node.ReservedResources == nil {
15741580
node.ReservedResources = &structs.NodeReservedResources{}

client/lib/numalib/detect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SystemScanner interface {
1818
// a single Topology, which can then be used to answer questions about the CPU
1919
// topology of the system.
2020
func Scan(scanners []SystemScanner) *Topology {
21-
top := new(Topology)
21+
top := &Topology{}
2222
for _, scanner := range scanners {
2323
scanner.ScanSystem(top)
2424
}

nomad/structs/cpucompat_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (n *NodeResources) Compatibility() {
2828
// the LegacyNodeCpuResources field, and so we synthesize a pseudo
2929
// NodeProcessorResources field
3030
n.Processors.Topology = topologyFromLegacy(n.Cpu)
31-
} else if !n.Processors.empty() {
31+
} else if !n.Processors.Empty() {
3232
// When we receive a node update from a 1.7+ client it contains a
3333
// NodeProcessorResources field, and we populate the LegacyNodeCpuResources
3434
// field using that information.

nomad/structs/cpucompat_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (n *NodeResources) Compatibility() {
3131
// the LegacyNodeCpuResources field, and so we synthesize a pseudo
3232
// NodeProcessorResources field
3333
n.Processors.Topology = topologyFromLegacy(n.Cpu)
34-
} else if !n.Processors.empty() {
34+
} else if !n.Processors.Empty() {
3535
// When we receive a node update from a 1.7+ client it contains a
3636
// NodeProcessorResources field, and we populate the LegacyNodeCpuResources
3737
// field using that information.

nomad/structs/numa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ type NodeProcessorResources struct {
128128

129129
// partial struct serialization / copy / merge sadness means this struct can
130130
// exist with no data, which is a condition we must detect during the upgrade path
131-
func (r NodeProcessorResources) empty() bool {
131+
func (r NodeProcessorResources) Empty() bool {
132132
return r.Topology == nil || len(r.Topology.Cores) == 0
133133
}
134134

nomad/structs/structs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/hashicorp/go-version"
3737
"github.com/hashicorp/nomad/acl"
3838
"github.com/hashicorp/nomad/client/lib/idset"
39+
"github.com/hashicorp/nomad/client/lib/numalib"
3940
"github.com/hashicorp/nomad/client/lib/numalib/hw"
4041
"github.com/hashicorp/nomad/command/agent/host"
4142
"github.com/hashicorp/nomad/command/agent/pprof"
@@ -2258,6 +2259,12 @@ func (n *Node) Canonicalize() {
22582259
n.NodeResources.NodeNetworks = append(n.NodeResources.NodeNetworks, nnr)
22592260
}
22602261
}
2262+
2263+
if n.NodeResources.Processors.Empty() {
2264+
n.NodeResources.Processors = NodeProcessorResources{
2265+
Topology: &numalib.Topology{},
2266+
}
2267+
}
22612268
}
22622269
}
22632270

0 commit comments

Comments
 (0)