From 69d029bddbd046d1ce79a99a6d6d39d03d137cde Mon Sep 17 00:00:00 2001 From: Hanna Lee Date: Tue, 20 Jul 2021 22:36:17 -0400 Subject: [PATCH] Add syncTicker.Stop() --- pkg/kubelet/status/status_manager.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/status/status_manager.go b/pkg/kubelet/status/status_manager.go index 7ec6d2b51a8..bd3b58b1c36 100644 --- a/pkg/kubelet/status/status_manager.go +++ b/pkg/kubelet/status/status_manager.go @@ -157,9 +157,10 @@ func (m *manager) Start() { } klog.InfoS("Starting to sync pod status with apiserver") - syncTicker := time.NewTicker(syncPeriod).C + syncTicker := time.NewTicker(syncPeriod) // syncPod and syncBatch share the same go routine to avoid sync races. go wait.Forever(func() { + defer syncTicker.Stop() for { select { case syncRequest := <-m.podStatusChannel: @@ -168,7 +169,7 @@ func (m *manager) Start() { "statusVersion", syncRequest.status.version, "status", syncRequest.status.status) m.syncPod(syncRequest.podUID, syncRequest.status) - case <-syncTicker: + case <-syncTicker.C: klog.V(5).InfoS("Status Manager: syncing batch") // remove any entries in the status channel since the batch will handle them for i := len(m.podStatusChannel); i > 0; i-- {