diff --git a/test/e2e/framework/deployment/fixtures.go b/test/e2e/framework/deployment/fixtures.go index 41acc99b125..c69feb3c2cf 100644 --- a/test/e2e/framework/deployment/fixtures.go +++ b/test/e2e/framework/deployment/fixtures.go @@ -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) }