Merge pull request #4474 from hashicorp/b-4463
scheduler: fixed nil panic and clearer error handling
This commit is contained in:
commit
2f202e20b9
|
@ -592,14 +592,18 @@ func updateRescheduleTracker(alloc *structs.Allocation, prev *structs.Allocation
|
||||||
}
|
}
|
||||||
|
|
||||||
// findPreferredNode finds the preferred node for an allocation
|
// findPreferredNode finds the preferred node for an allocation
|
||||||
func (s *GenericScheduler) findPreferredNode(place placementResult) (node *structs.Node, err error) {
|
func (s *GenericScheduler) findPreferredNode(place placementResult) (*structs.Node, error) {
|
||||||
if prev := place.PreviousAllocation(); prev != nil && place.TaskGroup().EphemeralDisk.Sticky == true {
|
if prev := place.PreviousAllocation(); prev != nil && place.TaskGroup().EphemeralDisk.Sticky == true {
|
||||||
var preferredNode *structs.Node
|
var preferredNode *structs.Node
|
||||||
ws := memdb.NewWatchSet()
|
ws := memdb.NewWatchSet()
|
||||||
preferredNode, err = s.state.NodeByID(ws, prev.NodeID)
|
preferredNode, err = s.state.NodeByID(ws, prev.NodeID)
|
||||||
if preferredNode.Ready() {
|
if err != nil {
|
||||||
node = preferredNode
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if preferredNode != nil && preferredNode.Ready() {
|
||||||
|
return preferredNode, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue