Skip to content

Commit de1f113

Browse files
committed
Merge pull request #4965 from hashicorp/b-gc-running
Don't GC running but desired stop allocations
1 parent 848c97e commit de1f113

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

nomad/core_sched.go

+6
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ func allocGCEligible(a *structs.Allocation, job *structs.Job, gcTime time.Time,
618618
return false
619619
}
620620

621+
// If the allocation is still running on the client we can not garbage
622+
// collect it.
623+
if a.ClientStatus == structs.AllocClientStatusRunning {
624+
return false
625+
}
626+
621627
// If the job is deleted, stopped or dead all allocs can be removed
622628
if job == nil || job.Stop || job.Status == structs.JobStatusDead {
623629
return true

nomad/core_sched_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,16 @@ func TestAllocation_GCEligible(t *testing.T) {
19721972
ThresholdIndex: 90,
19731973
ShouldGC: false,
19741974
},
1975+
{
1976+
Desc: "Don't GC when non terminal on client and job dead",
1977+
ClientStatus: structs.AllocClientStatusRunning,
1978+
DesiredStatus: structs.AllocDesiredStatusStop,
1979+
JobStatus: structs.JobStatusDead,
1980+
GCTime: fail,
1981+
ModifyIndex: 90,
1982+
ThresholdIndex: 90,
1983+
ShouldGC: false,
1984+
},
19751985
{
19761986
Desc: "GC when terminal but not failed ",
19771987
ClientStatus: structs.AllocClientStatusComplete,

0 commit comments

Comments
 (0)