Merge pull request #87255 from klueska/upstream-remove-redundant-active-pods-check

Remove check for empty activePods list in CPUManager removeStaleState
This commit is contained in:
Kubernetes Prow Robot 2020-01-20 09:05:50 -08:00 committed by GitHub
commit 37ee6425ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -321,12 +321,6 @@ func (m *manager) removeStaleState() {
// Get the list of active pods. // Get the list of active pods.
activePods := m.activePods() activePods := m.activePods()
if len(activePods) == 0 {
// If there are no active pods, skip the removal of stale state.
// Since this function is called periodically, we will just try again
// next time this function is called.
return
}
// Build a list of (podUID, containerName) pairs for all containers in all active Pods. // Build a list of (podUID, containerName) pairs for all containers in all active Pods.
activeContainers := make(map[string]map[string]struct{}) activeContainers := make(map[string]map[string]struct{})

View File

@ -23,6 +23,7 @@ import (
cadvisorapi "github.com/google/cadvisor/info/v1" cadvisorapi "github.com/google/cadvisor/info/v1"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state" "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/topology" "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/topology"
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset" "k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
@ -238,6 +239,18 @@ func TestGetTopologyHints(t *testing.T) {
for _, tc := range tcases { for _, tc := range tcases {
topology, _ := topology.Discover(&machineInfo, numaNodeInfo) topology, _ := topology.Discover(&machineInfo, numaNodeInfo)
var activePods []*v1.Pod
for p := range tc.assignments {
pod := v1.Pod{}
pod.UID = types.UID(p)
for c := range tc.assignments[p] {
container := v1.Container{}
container.Name = c
pod.Spec.Containers = append(pod.Spec.Containers, container)
}
activePods = append(activePods, &pod)
}
m := manager{ m := manager{
policy: &staticPolicy{ policy: &staticPolicy{
topology: topology, topology: topology,
@ -247,7 +260,7 @@ func TestGetTopologyHints(t *testing.T) {
defaultCPUSet: tc.defaultCPUSet, defaultCPUSet: tc.defaultCPUSet,
}, },
topology: topology, topology: topology,
activePods: func() []*v1.Pod { return nil }, activePods: func() []*v1.Pod { return activePods },
podStatusProvider: mockPodStatusProvider{}, podStatusProvider: mockPodStatusProvider{},
sourcesReady: &sourcesReadyStub{}, sourcesReady: &sourcesReadyStub{},
} }