From fca95638532e1736d264925f43cdd5fe1437aed7 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Tue, 6 Jan 2026 14:56:35 -0800 Subject: [PATCH] Remove unused config.Sync function. --- pkg/kubelet/config/config.go | 24 ------------------------ pkg/kubelet/config/config_test.go | 20 ++++---------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/pkg/kubelet/config/config.go b/pkg/kubelet/config/config.go index 485481a22b3..c793d2c7a45 100644 --- a/pkg/kubelet/config/config.go +++ b/pkg/kubelet/config/config.go @@ -99,11 +99,6 @@ func (c *PodConfig) Updates() <-chan kubetypes.PodUpdate { return c.updates } -// Sync requests the full configuration be delivered to the update channel. -func (c *PodConfig) Sync() { - c.pods.sync() -} - // podStorage manages the current pod state at any point in time and ensures updates // to the channel are delivered in order. Note that this object is an in-memory source of // "truth" and on creation contains zero entries. Once all previously read sources are @@ -405,25 +400,6 @@ func checkAndUpdatePod(existing, ref *v1.Pod) (needUpdate, needReconcile, needGr return } -// sync sends a copy of the current state through the update channel. -func (s *podStorage) sync() { - s.updateLock.Lock() - defer s.updateLock.Unlock() - s.updates <- kubetypes.PodUpdate{Pods: s.mergedState().([]*v1.Pod), Op: kubetypes.SET, Source: kubetypes.AllSource} -} - -func (s *podStorage) mergedState() interface{} { - s.podLock.RLock() - defer s.podLock.RUnlock() - pods := make([]*v1.Pod, 0) - for _, sourcePods := range s.pods { - for _, podRef := range sourcePods { - pods = append(pods, podRef.DeepCopy()) - } - } - return pods -} - func copyPods(sourcePods []*v1.Pod) []*v1.Pod { pods := []*v1.Pod{} for _, source := range sourcePods { diff --git a/pkg/kubelet/config/config_test.go b/pkg/kubelet/config/config_test.go index 8a96ce67dfb..24692fb6eb1 100644 --- a/pkg/kubelet/config/config_test.go +++ b/pkg/kubelet/config/config_test.go @@ -144,49 +144,40 @@ func expectNoPodUpdate(t *testing.T, ch <-chan kubetypes.PodUpdate) { func TestNewPodAdded(t *testing.T) { tCtx := ktesting.Init(t) - channel, ch, config := createPodConfigTester(tCtx) + channel, ch, _ := createPodConfigTester(tCtx) // see an update podUpdate := createSourceUpdate(CreateValidPod("foo", "new")) channel <- podUpdate expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.ADD, TestSource, CreateValidPod("foo", "new"))) - - config.Sync() - expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.SET, kubetypes.AllSource, CreateValidPod("foo", "new"))) } func TestNewPodAddedInvalidNamespace(t *testing.T) { tCtx := ktesting.Init(t) - channel, ch, config := createPodConfigTester(tCtx) + channel, ch, _ := createPodConfigTester(tCtx) // see an update podUpdate := createSourceUpdate(CreateValidPod("foo", "")) channel <- podUpdate expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.ADD, TestSource, CreateValidPod("foo", ""))) - - config.Sync() - expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.SET, kubetypes.AllSource, CreateValidPod("foo", ""))) } func TestNewPodAddedDefaultNamespace(t *testing.T) { tCtx := ktesting.Init(t) - channel, ch, config := createPodConfigTester(tCtx) + channel, ch, _ := createPodConfigTester(tCtx) // see an update podUpdate := createSourceUpdate(CreateValidPod("foo", "default")) channel <- podUpdate expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.ADD, TestSource, CreateValidPod("foo", "default"))) - - config.Sync() - expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.SET, kubetypes.AllSource, CreateValidPod("foo", "default"))) } func TestNewPodAddedDifferentNamespaces(t *testing.T) { tCtx := ktesting.Init(t) - channel, ch, config := createPodConfigTester(tCtx) + channel, ch, _ := createPodConfigTester(tCtx) // see an update pod1 := CreateValidPod("foo", "default") @@ -199,9 +190,6 @@ func TestNewPodAddedDifferentNamespaces(t *testing.T) { podUpdate = createSourceUpdate(pod1, pod2) channel <- podUpdate expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.ADD, TestSource, CreateValidPod("foo", "new"))) - - config.Sync() - expectPodUpdate(t, ch, CreatePodUpdate(kubetypes.SET, kubetypes.AllSource, CreateValidPod("foo", "default"), CreateValidPod("foo", "new"))) } func TestInvalidPodFiltered(t *testing.T) {