diff --git a/pkg/kubectl/rolling_updater.go b/pkg/kubectl/rolling_updater.go index ea730072c31..48a4f05052e 100644 --- a/pkg/kubectl/rolling_updater.go +++ b/pkg/kubectl/rolling_updater.go @@ -739,11 +739,6 @@ func AddDeploymentKeyToReplicationController(oldRc *corev1.ReplicationController if oldRc.Spec.Selector == nil { oldRc.Spec.Selector = map[string]string{} } - // Copy the old selector, so that we can scrub out any orphaned pods - selectorCopy := map[string]string{} - for k, v := range oldRc.Spec.Selector { - selectorCopy[k] = v - } applyUpdate = func(rc *corev1.ReplicationController) { rc.Spec.Selector[deploymentKey] = deploymentValue } @@ -755,7 +750,7 @@ func AddDeploymentKeyToReplicationController(oldRc *corev1.ReplicationController // Clean up any orphaned pods that don't have the new label, this can happen if the rc manager // doesn't see the update to its pod template and creates a new pod with the old labels after // we've finished re-adopting existing pods to the rc. - selector = labels.SelectorFromSet(selectorCopy) + selector = labels.SelectorFromSet(oldRc.Spec.Selector) options = metav1.ListOptions{LabelSelector: selector.String()} if podList, err = podClient.Pods(namespace).List(options); err != nil { return nil, err