diff --git a/test/e2e/log_size_monitoring.go b/test/e2e/log_size_monitoring.go index 5f1eef7663a..30de88d2b4b 100644 --- a/test/e2e/log_size_monitoring.go +++ b/test/e2e/log_size_monitoring.go @@ -218,6 +218,15 @@ func (g *LogSizeGatherer) Run() { } } +func (g *LogSizeGatherer) pushWorkItem(workItem WorkItem) { + select { + case <-time.After(time.Duration(workItem.backoffMultiplier) * pollingPeriod): + g.workChannel <- workItem + case <-g.stopChannel: + return + } +} + // Work does a single unit of work: tries to take out a WorkItem from the queue, ssh-es into a given machine, // gathers data, writes it to the shared map, and creates a gorouting which reinserts work item into // the queue with a delay. Returns false if worker should exit. @@ -239,7 +248,7 @@ func (g *LogSizeGatherer) Work() bool { if workItem.backoffMultiplier < 128 { workItem.backoffMultiplier *= 2 } - g.workChannel <- workItem + go g.pushWorkItem(workItem) return true } workItem.backoffMultiplier = 1 @@ -255,13 +264,6 @@ func (g *LogSizeGatherer) Work() bool { } g.data.AddNewData(workItem.ip, path, now, size) } - go func() { - select { - case <-time.After(time.Duration(workItem.backoffMultiplier) * pollingPeriod): - g.workChannel <- workItem - case <-g.stopChannel: - return - } - }() + go g.pushWorkItem(workItem) return true }