From a28969355e292db0bfb80d28f28e1f4b761a4368 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Wed, 7 Aug 2019 10:33:22 -0700 Subject: [PATCH] Fix race condition around worker ID generation in podcontroller.go --- node/podcontroller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/node/podcontroller.go b/node/podcontroller.go index ac0810401..a923c5d7c 100644 --- a/node/podcontroller.go +++ b/node/podcontroller.go @@ -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()) }