diff --git a/scheduler/context.go b/scheduler/context.go index 0a765944f..01f61eed9 100644 --- a/scheduler/context.go +++ b/scheduler/context.go @@ -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 diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index baed71e73..518280d07 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -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)