scheduler: Use AllocsByNodeTerminal to avoid filtering

This commit is contained in:
Armon Dadgar 2016-02-20 11:29:15 -08:00
parent 2d7236eb95
commit 35741fcedd
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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)