Fix race condition around worker ID generation in podcontroller.go

This commit is contained in:
Sargun Dhillon
2019-08-07 10:33:22 -07:00
parent a87af0818f
commit a28969355e

View File

@@ -227,9 +227,10 @@ func (pc *PodController) Run(ctx context.Context, podSyncWorkers int) error {
log.G(ctx).Info("starting workers")
for id := 0; id < podSyncWorkers; id++ {
workerID := strconv.Itoa(id)
go wait.Until(func() {
// Use the worker's "index" as its ID so we can use it for tracing.
pc.runWorker(ctx, strconv.Itoa(id), pc.k8sQ)
pc.runWorker(ctx, workerID, pc.k8sQ)
}, time.Second, ctx.Done())
}