Skip to content

Commit 40049ae

Browse files
Merge pull request #21 from thedadams/fix-panic-on-shutdown
fix: stop adding to wait group on shutdown
2 parents 0dbe2ca + 985ad73 commit 40049ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/runtime/controller.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,19 @@ func (c *controller) runWorkers(ctx context.Context, workers int) {
263263

264264
for {
265265
obj, shutdown := queue.Get()
266-
267266
if shutdown {
268267
return
269268
}
270269

271270
// Acquire from the semaphore
272271
running <- struct{}{}
272+
273+
if queue.ShuttingDown() {
274+
// If we acquired after the workers were shutdown,
275+
// then drop this object and return instead of trying to add to the wait group, which will panic.
276+
return
277+
}
278+
273279
wait.Add(1)
274280

275281
go func() {

0 commit comments

Comments
 (0)