mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #80230 from tedyu/rolling-sel
Skip unnecessary copy of Selector
This commit is contained in:
commit
c1ebabed42
@ -739,11 +739,6 @@ func AddDeploymentKeyToReplicationController(oldRc *corev1.ReplicationController
|
|||||||
if oldRc.Spec.Selector == nil {
|
if oldRc.Spec.Selector == nil {
|
||||||
oldRc.Spec.Selector = map[string]string{}
|
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) {
|
applyUpdate = func(rc *corev1.ReplicationController) {
|
||||||
rc.Spec.Selector[deploymentKey] = deploymentValue
|
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
|
// 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
|
// 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.
|
// 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()}
|
options = metav1.ListOptions{LabelSelector: selector.String()}
|
||||||
if podList, err = podClient.Pods(namespace).List(options); err != nil {
|
if podList, err = podClient.Pods(namespace).List(options); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user