mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
fixed using reference to loop iterator (#105433)
* fixed using reference to loop iterator * fixed other for loops
This commit is contained in:
parent
edeab47b36
commit
3e6d122ee1
@ -99,12 +99,12 @@ func GetPodsForDeployment(client clientset.Interface, deployment *appsv1.Deploym
|
||||
}
|
||||
|
||||
ownedReplicaSets := make([]*appsv1.ReplicaSet, 0, len(allReplicaSets.Items))
|
||||
for _, rs := range allReplicaSets.Items {
|
||||
if !metav1.IsControlledBy(&rs, deployment) {
|
||||
for i := range allReplicaSets.Items {
|
||||
if !metav1.IsControlledBy(&allReplicaSets.Items[i], deployment) {
|
||||
continue
|
||||
}
|
||||
|
||||
ownedReplicaSets = append(ownedReplicaSets, &rs)
|
||||
ownedReplicaSets = append(ownedReplicaSets, &allReplicaSets.Items[i])
|
||||
}
|
||||
|
||||
// We ignore pod-template-hash because:
|
||||
@ -126,8 +126,8 @@ func GetPodsForDeployment(client clientset.Interface, deployment *appsv1.Deploym
|
||||
// see https://github.com/kubernetes/kubernetes/issues/40415
|
||||
// We deterministically choose the oldest new ReplicaSet.
|
||||
sort.Sort(replicaSetsByCreationTimestamp(ownedReplicaSets))
|
||||
for _, rs := range ownedReplicaSets {
|
||||
if !podTemplatesEqualsIgnoringHash(&rs.Spec.Template, &deployment.Spec.Template) {
|
||||
for i, rs := range ownedReplicaSets {
|
||||
if !podTemplatesEqualsIgnoringHash(&ownedReplicaSets[i].Spec.Template, &deployment.Spec.Template) {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -151,8 +151,8 @@ func GetPodsForDeployment(client clientset.Interface, deployment *appsv1.Deploym
|
||||
|
||||
replicaSetUID := replicaSet.UID
|
||||
ownedPods := &v1.PodList{Items: make([]v1.Pod, 0, len(allPods.Items))}
|
||||
for _, pod := range allPods.Items {
|
||||
controllerRef := metav1.GetControllerOf(&pod)
|
||||
for i, pod := range allPods.Items {
|
||||
controllerRef := metav1.GetControllerOf(&allPods.Items[i])
|
||||
if controllerRef != nil && controllerRef.UID == replicaSetUID {
|
||||
ownedPods.Items = append(ownedPods.Items, pod)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user