Skip to content

Commit

Permalink
scheduler: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nickethier committed Jul 5, 2018
1 parent 1acbf1d commit 3e7d430
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 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 err != nil {
return nil, err
}

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

0 comments on commit 3e7d430

Please sign in to comment.