update description of the alloc update factory function

This commit is contained in:
Alex Dadgar 2017-06-21 13:26:45 -07:00
parent ce2319be9b
commit 27a6e6b6d1
2 changed files with 8 additions and 4 deletions

View File

@ -384,7 +384,7 @@ func (s *GenericScheduler) computeJobAllocs() error {
allocs, _ = s.filterCompleteAllocs(allocs)
reconciler := NewAllocReconciler(s.ctx.Logger(),
newAllocUpdateFn(s.ctx, s.stack, s.eval.ID),
genericAllocUpdateFn(s.ctx, s.stack, s.eval.ID),
s.batch, s.eval.JobID, s.job, s.deployment, allocs, tainted)
results := reconciler.Compute()

View File

@ -733,9 +733,13 @@ func updateNonTerminalAllocsToLost(plan *structs.Plan, tainted map[string]*struc
}
}
// newAllocUpdateFn is a factory for the scheduler to create an allocUpdateType
// function for the reconciler
func newAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateType {
// genericAllocUpdateFn is a factory for the scheduler to create an allocUpdateType
// function to be passed into the reconciler. The factory takes objects that
// exist only in the scheduler context and returns a function that can be used
// by the reconciler to make decsions about how to update an allocation. The
// factory allows the reconciler to be unaware of how to determine the type of
// update necessary and can minimize the set of objects it is exposed to.
func genericAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateType {
return func(existing *structs.Allocation, newJob *structs.Job, newTG *structs.TaskGroup) (ignore, destructive bool, updated *structs.Allocation) {
// Same index, so nothing to do
if existing.Job.JobModifyIndex == newJob.JobModifyIndex {