Merge pull request #4048 from hashicorp/f-system

Correct status desc on draining system allocs
This commit is contained in:
Alex Dadgar 2018-03-27 10:12:36 -07:00 committed by GitHub
commit 8b0d8df442
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View file

@ -35,6 +35,10 @@ const (
// allocInPlace is the status used when speculating on an in-place update
allocInPlace = "alloc updating in-place"
// allocNodeTainted is the status used when stopping an alloc because it's
// node is tainted.
allocNodeTainted = "alloc not needed as node is tainted"
// blockedEvalMaxPlanDesc is the description used for blocked evals that are
// a result of hitting the max number of plan attempts
blockedEvalMaxPlanDesc = "created due to placement conflicts"

View file

@ -14,10 +14,6 @@ const (
// we will attempt to schedule if we continue to hit conflicts for system
// jobs.
maxSystemScheduleAttempts = 5
// allocNodeTainted is the status used when stopping an alloc because it's
// node is tainted.
allocNodeTainted = "alloc not needed as node is tainted"
)
// SystemScheduler is used for 'system' jobs. This scheduler is
@ -212,6 +208,11 @@ func (s *SystemScheduler) computeJobAllocs() error {
s.plan.AppendUpdate(e.Alloc, structs.AllocDesiredStatusStop, allocNotNeeded, "")
}
// Add all the allocs to migrate
for _, e := range diff.migrate {
s.plan.AppendUpdate(e.Alloc, structs.AllocDesiredStatusStop, allocNodeTainted, "")
}
// Lost allocations should be transitioned to desired status stop and client
// status lost.
for _, e := range diff.lost {

View file

@ -214,11 +214,6 @@ func diffSystemAllocs(job *structs.Job, nodes []*structs.Node, taintedNodes map[
}
}
// Migrate does not apply to system jobs and instead should be marked as
// stop because if a node is tainted, the job is invalid on that node.
diff.stop = append(diff.stop, diff.migrate...)
diff.migrate = nil
result.Append(diff)
}

View file

@ -265,12 +265,12 @@ func TestDiffSystemAllocs(t *testing.T) {
}
// We should stop the third alloc
if len(stop) != 1 || stop[0].Alloc != allocs[2] {
if len(stop) != 0 {
t.Fatalf("bad: %#v", stop)
}
// There should be no migrates.
if len(migrate) != 0 {
if len(migrate) != 1 || migrate[0].Alloc != allocs[2] {
t.Fatalf("bad: %#v", migrate)
}