Skip to content

Commit

Permalink
Merge pull request #4474 from hashicorp/b-4463
Browse files Browse the repository at this point in the history
scheduler: fixed nil panic and clearer error handling
  • Loading branch information
nickethier authored Jul 11, 2018
2 parents b8b3d03 + 3e7d430 commit 4b84f0a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,18 @@ func updateRescheduleTracker(alloc *structs.Allocation, prev *structs.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 {
var preferredNode *structs.Node
ws := memdb.NewWatchSet()
preferredNode, err = s.state.NodeByID(ws, prev.NodeID)
if preferredNode.Ready() {
node = preferredNode
if err != nil {
return nil, err
}

if preferredNode != nil && preferredNode.Ready() {
return preferredNode, nil
}
}
return
return nil, nil
}

0 comments on commit 4b84f0a

Please sign in to comment.