Skip to content

Commit 37ee642

Browse files
authored
Merge pull request kubernetes#87255 from klueska/upstream-remove-redundant-active-pods-check
Remove check for empty activePods list in CPUManager removeStaleState
2 parents b869053 + 34b942a commit 37ee642

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pkg/kubelet/cm/cpumanager/cpu_manager.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,6 @@ func (m *manager) removeStaleState() {
321321

322322
// Get the list of active pods.
323323
activePods := m.activePods()
324-
if len(activePods) == 0 {
325-
// If there are no active pods, skip the removal of stale state.
326-
// Since this function is called periodically, we will just try again
327-
// next time this function is called.
328-
return
329-
}
330324

331325
// Build a list of (podUID, containerName) pairs for all containers in all active Pods.
332326
activeContainers := make(map[string]map[string]struct{})

pkg/kubelet/cm/cpumanager/topology_hints_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
cadvisorapi "github.com/google/cadvisor/info/v1"
2525
v1 "k8s.io/api/core/v1"
26+
"k8s.io/apimachinery/pkg/types"
2627
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
2728
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/topology"
2829
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
@@ -238,6 +239,18 @@ func TestGetTopologyHints(t *testing.T) {
238239
for _, tc := range tcases {
239240
topology, _ := topology.Discover(&machineInfo, numaNodeInfo)
240241

242+
var activePods []*v1.Pod
243+
for p := range tc.assignments {
244+
pod := v1.Pod{}
245+
pod.UID = types.UID(p)
246+
for c := range tc.assignments[p] {
247+
container := v1.Container{}
248+
container.Name = c
249+
pod.Spec.Containers = append(pod.Spec.Containers, container)
250+
}
251+
activePods = append(activePods, &pod)
252+
}
253+
241254
m := manager{
242255
policy: &staticPolicy{
243256
topology: topology,
@@ -247,7 +260,7 @@ func TestGetTopologyHints(t *testing.T) {
247260
defaultCPUSet: tc.defaultCPUSet,
248261
},
249262
topology: topology,
250-
activePods: func() []*v1.Pod { return nil },
263+
activePods: func() []*v1.Pod { return activePods },
251264
podStatusProvider: mockPodStatusProvider{},
252265
sourcesReady: &sourcesReadyStub{},
253266
}

0 commit comments

Comments
 (0)