Skip to content

Commit

Permalink
core: apply node resources compatibility upon fsm rstore
Browse files Browse the repository at this point in the history
Handle the case where an upgraded server dequeus an evaluation before
a client triggers a new fingerprint - which would be needed to cause
the compatibility fix to run. By running the compat fix on restore the
server will immediately have the compatible pseudo topology to use.
  • Loading branch information
shoenig committed Oct 19, 2023
1 parent 613df11 commit e79311c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,13 @@ func (n *Node) Canonicalize() {
n.SchedulingEligibility = NodeSchedulingEligible
}

// COMPAT remove in 1.9+
// In v1.7 we introduce Topology into the NodeResources struct which the client
// will fingerprint. Since the upgrade path must cover servers that get upgraded
// before clients which will send the old struct, we synthesize a psuedo topology

Check failure on line 2244 in nomad/structs/structs.go

View workflow job for this annotation

GitHub Actions / checks / checks

`psuedo` is a misspelling of `pseudo` (misspell)
// given the old struct data.
n.NodeResources.Compatibility()

// COMPAT remove in 1.0
// In v0.12.0 we introduced a separate node specific network resource struct
// so we need to covert any pre 0.12 clients to the correct struct
Expand Down Expand Up @@ -3123,6 +3130,11 @@ type NodeResources struct {
// Compatibility will translate the LegacyNodeCpuResources into NodeProcessor
// Resources, or the other way around as needed.
func (n *NodeResources) Compatibility() {
// If resources are not set there is nothing to do.
if n == nil {
return
}

// Copy values from n.Processors to n.Cpu for compatibility
//
// COMPAT: added in Nomad 1.7; can be removed in 1.9+
Expand Down Expand Up @@ -3170,7 +3182,8 @@ func (n *NodeResources) Copy() *NodeResources {
}
}

// apply compatibility fixups
// COMPAT remove in 1.9+
// apply compatibility fixups covering node topology
n.Compatibility()

return newN
Expand Down Expand Up @@ -3233,7 +3246,8 @@ func (n *NodeResources) Merge(o *NodeResources) {
}
}

// apply compatibility fixups
// COMPAT remove in 1.9+
// apply compatibility fixups covering node topology
n.Compatibility()
}

Expand Down

0 comments on commit e79311c

Please sign in to comment.