diff --git a/pkg/controller/controller_ref_manager.go b/pkg/controller/controller_ref_manager.go index 226c9b8d3ec..d3bc26473a0 100644 --- a/pkg/controller/controller_ref_manager.go +++ b/pkg/controller/controller_ref_manager.go @@ -163,11 +163,6 @@ func (m *PodControllerRefManager) ClaimPods(pods []*v1.Pod) ([]*v1.Pod, error) { } for _, pod := range pods { - if !IsPodActive(pod) { - glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v", - pod.Namespace, pod.Name, pod.Status.Phase, pod.DeletionTimestamp) - continue - } ok, err := m.claimObject(pod, adopt, release) if err != nil { errlist = append(errlist, err) diff --git a/pkg/controller/replicaset/replica_set.go b/pkg/controller/replicaset/replica_set.go index 665f08578ba..83c67819bf9 100644 --- a/pkg/controller/replicaset/replica_set.go +++ b/pkg/controller/replicaset/replica_set.go @@ -541,18 +541,24 @@ func (rsc *ReplicaSetController) syncReplicaSet(key string) error { return nil } - // NOTE: filteredPods are pointing to objects from cache - if you need to - // modify them, you need to copy it first. - // TODO: Do the List and Filter in a single pass, or use an index. - var filteredPods []*v1.Pod // list all pods to include the pods that don't match the rs`s selector // anymore but has the stale controller ref. + // TODO: Do the List and Filter in a single pass, or use an index. pods, err := rsc.podLister.Pods(rs.Namespace).List(labels.Everything()) if err != nil { return err } + // Ignore inactive pods. + var filteredPods []*v1.Pod + for _, pod := range pods { + if controller.IsPodActive(pod) { + filteredPods = append(filteredPods, pod) + } + } cm := controller.NewPodControllerRefManager(rsc.podControl, rs, selector, controllerKind) - filteredPods, err = cm.ClaimPods(pods) + // NOTE: filteredPods are pointing to objects from cache - if you need to + // modify them, you need to copy it first. + filteredPods, err = cm.ClaimPods(filteredPods) if err != nil { return err } diff --git a/pkg/controller/replication/replication_controller.go b/pkg/controller/replication/replication_controller.go index df34de1c63f..9a6f8cff16e 100644 --- a/pkg/controller/replication/replication_controller.go +++ b/pkg/controller/replication/replication_controller.go @@ -559,17 +559,23 @@ func (rm *ReplicationManager) syncReplicationController(key string) error { rcNeedsSync := rm.expectations.SatisfiedExpectations(key) trace.Step("Expectations restored") - // NOTE: filteredPods are pointing to objects from cache - if you need to - // modify them, you need to copy it first. - // TODO: Do the List and Filter in a single pass, or use an index. - var filteredPods []*v1.Pod // list all pods to include the pods that don't match the rc's selector // anymore but has the stale controller ref. + // TODO: Do the List and Filter in a single pass, or use an index. pods, err := rm.podLister.Pods(rc.Namespace).List(labels.Everything()) if err != nil { return err } + // Ignore inactive pods. + var filteredPods []*v1.Pod + for _, pod := range pods { + if controller.IsPodActive(pod) { + filteredPods = append(filteredPods, pod) + } + } cm := controller.NewPodControllerRefManager(rm.podControl, rc, labels.Set(rc.Spec.Selector).AsSelectorPreValidated(), controllerKind) + // NOTE: filteredPods are pointing to objects from cache - if you need to + // modify them, you need to copy it first. filteredPods, err = cm.ClaimPods(pods) if err != nil { return err