mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-30 08:51:53 +00:00
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
This commit is contained in:
parent
cc9d424da8
commit
f39ca994bd
@ -55,7 +55,13 @@ func newQueue(c clock.Clock, metrics queueMetrics, updatePeriod time.Duration) *
|
|||||||
metrics: metrics,
|
metrics: metrics,
|
||||||
unfinishedWorkUpdatePeriod: updatePeriod,
|
unfinishedWorkUpdatePeriod: updatePeriod,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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()
|
go t.updateUnfinishedWorkLoop()
|
||||||
|
}
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user