Skip to content

Commit ed1113b

Browse files
authored
allocrunner: automatically stop batch types allocations. (#26)
Previously, when running batch type jobs (batch/sysbatch), the allocs would run until the user initiated shutdown. This is not how batch workloads run and caused load testing problems as nodes would fill with running workload. This problem can be overcome by using the "real" allocrunner, but adds resource overhead on the nodesim process. Automatically stopping batch workload mimics real work and allows us to use the simulated allocrunner for a lighter overhead. This means benchmarking can be cheaper and easier to run.
1 parent 7f0beac commit ed1113b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

allocrunnersim/allocrunnersim.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ func (ar *simulatedAllocRunner) Run() {
174174
ar.allocStateLock.Unlock()
175175

176176
ar.updateAllocAndSendUpdate(taskStates)
177+
178+
// Who wants to live forever?
179+
//
180+
// Batch and sysbatch jobs certainly don't, so after a little pause to
181+
// simulate the allocation has done something, we stop it. This is useful
182+
// for load testing, as we can continually dispatch jobs, without nodes
183+
// becoming resource exhausted and still use the lighter-weight simulated
184+
// alloc-runner.
185+
//
186+
// Other job types which are meant to run forever, must be stopped by a
187+
// user initiated command.
188+
switch ar.alloc.Job.Type {
189+
case structs.JobTypeBatch, structs.JobTypeSysBatch:
190+
go func() {
191+
time.Sleep(5 * time.Second)
192+
ar.stopAll()
193+
}()
194+
}
177195
}
178196

179197
// updateAllocAndSendUpdate is a small helper that builds a new allocation

0 commit comments

Comments
 (0)