scheduler: Use AllocsByNodeTerminal to avoid filtering
This commit is contained in:
parent
2d7236eb95
commit
35741fcedd
|
@ -107,15 +107,12 @@ func (e *EvalContext) Reset() {
|
|||
}
|
||||
|
||||
func (e *EvalContext) ProposedAllocs(nodeID string) ([]*structs.Allocation, error) {
|
||||
// Get the existing allocations
|
||||
existingAlloc, err := e.state.AllocsByNode(nodeID)
|
||||
// Get the existing allocations that are non-terminal
|
||||
existingAlloc, err := e.state.AllocsByNodeTerminal(nodeID, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Filter on alloc state
|
||||
existingAlloc = structs.FilterTerminalAllocs(existingAlloc)
|
||||
|
||||
// Determine the proposed allocation by first removing allocations
|
||||
// that are planned evictions and adding the new allocations.
|
||||
proposed := existingAlloc
|
||||
|
|
|
@ -63,6 +63,9 @@ type State interface {
|
|||
// AllocsByNode returns all the allocations by node
|
||||
AllocsByNode(node string) ([]*structs.Allocation, error)
|
||||
|
||||
// AllocsByNodeTerminal returns all the allocations by node filtering by terminal status
|
||||
AllocsByNodeTerminal(node string, terminal bool) ([]*structs.Allocation, error)
|
||||
|
||||
// GetNodeByID is used to lookup a node by ID
|
||||
NodeByID(nodeID string) (*structs.Node, error)
|
||||
|
||||
|
|
Loading…
Reference in New Issue