From e78b3e8dfed0a03ea83106d5a624e98e7300c3cd Mon Sep 17 00:00:00 2001 From: Hanna Lee Date: Wed, 3 Nov 2021 19:41:25 -0400 Subject: [PATCH] Use nolint directive instead of stopping ticker, per liggit's suggestion --- pkg/kubelet/status/status_manager.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/status/status_manager.go b/pkg/kubelet/status/status_manager.go index bd3b58b1c36..051f0edda90 100644 --- a/pkg/kubelet/status/status_manager.go +++ b/pkg/kubelet/status/status_manager.go @@ -157,10 +157,12 @@ func (m *manager) Start() { } klog.InfoS("Starting to sync pod status with apiserver") - syncTicker := time.NewTicker(syncPeriod) + + //nolint:staticcheck // SA1015 Ticker can leak since this is only called once and doesn't handle termination. + syncTicker := time.NewTicker(syncPeriod).C + // 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: @@ -169,7 +171,7 @@ func (m *manager) Start() { "statusVersion", syncRequest.status.version, "status", syncRequest.status.status) m.syncPod(syncRequest.podUID, syncRequest.status) - case <-syncTicker.C: + case <-syncTicker: 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-- {