Store the job on allocations that are from stopped jobs
This commit is contained in:
parent
fbf6275160
commit
a9d410dbee
|
@ -2421,7 +2421,15 @@ type Plan struct {
|
||||||
func (p *Plan) AppendUpdate(alloc *Allocation, status, desc string) {
|
func (p *Plan) AppendUpdate(alloc *Allocation, status, desc string) {
|
||||||
newAlloc := new(Allocation)
|
newAlloc := new(Allocation)
|
||||||
*newAlloc = *alloc
|
*newAlloc = *alloc
|
||||||
newAlloc.Job = nil // Normalize the job
|
|
||||||
|
// If the job is not set in the plan we are deregistering a job so we
|
||||||
|
// extract the job from the allocation.
|
||||||
|
if p.Job == nil && newAlloc.Job != nil {
|
||||||
|
p.Job = newAlloc.Job
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize the job
|
||||||
|
newAlloc.Job = nil
|
||||||
newAlloc.DesiredStatus = status
|
newAlloc.DesiredStatus = status
|
||||||
newAlloc.DesiredDescription = desc
|
newAlloc.DesiredDescription = desc
|
||||||
node := alloc.NodeID
|
node := alloc.NodeID
|
||||||
|
|
|
@ -634,6 +634,13 @@ func TestServiceSched_JobDeregister(t *testing.T) {
|
||||||
out, err := h.State.AllocsByJob(job.ID)
|
out, err := h.State.AllocsByJob(job.ID)
|
||||||
noErr(t, err)
|
noErr(t, err)
|
||||||
|
|
||||||
|
// Ensure that the job field on the allocation is still populated
|
||||||
|
for _, alloc := range out {
|
||||||
|
if alloc.Job == nil {
|
||||||
|
t.Fatalf("bad: %#v", alloc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure no remaining allocations
|
// Ensure no remaining allocations
|
||||||
out = structs.FilterTerminalAllocs(out)
|
out = structs.FilterTerminalAllocs(out)
|
||||||
if len(out) != 0 {
|
if len(out) != 0 {
|
||||||
|
|
Loading…
Reference in a new issue