Remove unused config.Sync function.

This commit is contained in:
Tim Allclair
2026-01-06 14:56:35 -08:00
parent 414f4e2770
commit fca9563853
2 changed files with 4 additions and 40 deletions

View File

@@ -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 {

View File

@@ -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) {