From c659e43f1cfaaa9eaa2046b1b3d7b0f4fb9357ef Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Wed, 31 Aug 2016 14:06:31 -0700 Subject: [PATCH] Added some more comments --- nomad/structs/funcs.go | 2 +- scheduler/util.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nomad/structs/funcs.go b/nomad/structs/funcs.go index 5822d22f9..c4aaef7f5 100644 --- a/nomad/structs/funcs.go +++ b/nomad/structs/funcs.go @@ -29,7 +29,7 @@ func RemoveAllocs(alloc []*Allocation, remove []*Allocation) []*Allocation { } // FilterTerminalAllocs filters out all allocations in a terminal state and -// returns the terminal allocations +// returns the latest terminal allocations func FilterTerminalAllocs(allocs []*Allocation) ([]*Allocation, map[string]*Allocation) { terminalAllocsByName := make(map[string]*Allocation) n := len(allocs) diff --git a/scheduler/util.go b/scheduler/util.go index 6a85f5dc8..6218c1c9a 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -59,6 +59,13 @@ func (d *diffResult) Append(other *diffResult) { // need to be migrated (node is draining), the allocs that need to be evicted // (no longer required), those that should be ignored and those that are lost // that need to be replaced (running on a lost node). +// +// job is the job whose allocs is going to be diff-ed. +// taintedNodes is an index of the nodes which are either down or in drain mode +// by name. +// required is a set of allocations that must exist. +// allocs is a list of non terminal allocations. +// terminalAllocs is an index of the latest terminal allocations by name. func diffAllocs(job *structs.Job, taintedNodes map[string]*structs.Node, required map[string]*structs.TaskGroup, allocs []*structs.Allocation, terminalAllocs map[string]*structs.Allocation) *diffResult { @@ -153,6 +160,13 @@ func diffAllocs(job *structs.Job, taintedNodes map[string]*structs.Node, // diffSystemAllocs is like diffAllocs however, the allocations in the // diffResult contain the specific nodeID they should be allocated on. +// +// job is the job whose allocs is going to be diff-ed. +// nodes is a list of nodes in ready state. +// taintedNodes is an index of the nodes which are either down or in drain mode +// by name. +// allocs is a list of non terminal allocations. +// terminalAllocs is an index of the latest terminal allocations by name. func diffSystemAllocs(job *structs.Job, nodes []*structs.Node, taintedNodes map[string]*structs.Node, allocs []*structs.Allocation, terminalAllocs map[string]*structs.Allocation) *diffResult {