From f39ca994bda03aeba221e10f37b56aabd8e43957 Mon Sep 17 00:00:00 2001 From: Dan Ramich Date: Tue, 15 Sep 2020 16:21:48 -0600 Subject: [PATCH] Don't start goroutine for noMetrics Problem: When calling newQueue metrics can be of type noMetrics when just calling New. When doing this a new goroutine is created to update the metrics but in this case there are no metrics so it's just creating goroutines that don't do anything but consume resources. Solution: If the incoming metrics is of type noMetrics, don't start the goroutine Kubernetes-commit: de021396f81ff438899297a6f464c70113b58475 --- util/workqueue/queue.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/workqueue/queue.go b/util/workqueue/queue.go index 39009b8e..f7c14ddc 100644 --- a/util/workqueue/queue.go +++ b/util/workqueue/queue.go @@ -55,7 +55,13 @@ func newQueue(c clock.Clock, metrics queueMetrics, updatePeriod time.Duration) * metrics: metrics, unfinishedWorkUpdatePeriod: updatePeriod, } - go t.updateUnfinishedWorkLoop() + + // Don't start the goroutine for a type of noMetrics so we don't consume + // resources unnecessarily + if _, ok := metrics.(noMetrics); !ok { + go t.updateUnfinishedWorkLoop() + } + return t }