mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #61351 from shyamjvs/fix-rc-pod-running-testutil
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Wait for only enough no. of RC replicas to be running in testutil Fix https://github.com/kubernetes/kubernetes/issues/61189 /sig scalability /kind bug /priority important-soon /cc @wojtek-t ```release-note NONE ```
This commit is contained in:
commit
21ada0ee37
@ -2811,7 +2811,11 @@ func WaitForControlledPodsRunning(c clientset.Interface, ns, name string, kind s
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = testutils.WaitForPodsWithLabelRunning(c, ns, selector)
|
||||
replicas, err := getReplicasFromRuntimeObject(rtObject)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = testutils.WaitForEnoughPodsWithLabelRunning(c, ns, selector, int(replicas))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while waiting for replication controller %s pods to be running: %v", name, err)
|
||||
}
|
||||
|
@ -828,20 +828,29 @@ func StartPods(c clientset.Interface, replicas int, namespace string, podNamePre
|
||||
// Wait up to 10 minutes for all matching pods to become Running and at least one
|
||||
// matching pod exists.
|
||||
func WaitForPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector) error {
|
||||
return WaitForEnoughPodsWithLabelRunning(c, ns, label, -1)
|
||||
}
|
||||
|
||||
// Wait up to 10 minutes for at least 'replicas' many pods to be Running and at least
|
||||
// one matching pod exists. If 'replicas' is < 0, wait for all matching pods running.
|
||||
func WaitForEnoughPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector, replicas int) error {
|
||||
running := false
|
||||
PodStore := NewPodStore(c, ns, label, fields.Everything())
|
||||
defer PodStore.Stop()
|
||||
waitLoop:
|
||||
for start := time.Now(); time.Since(start) < 10*time.Minute; time.Sleep(5 * time.Second) {
|
||||
pods := PodStore.List()
|
||||
if len(pods) == 0 {
|
||||
continue waitLoop
|
||||
continue
|
||||
}
|
||||
runningPodsCount := 0
|
||||
for _, p := range pods {
|
||||
if p.Status.Phase != v1.PodRunning {
|
||||
continue waitLoop
|
||||
if p.Status.Phase == v1.PodRunning {
|
||||
runningPodsCount++
|
||||
}
|
||||
}
|
||||
if (replicas < 0 && runningPodsCount < len(pods)) || (runningPodsCount < replicas) {
|
||||
continue
|
||||
}
|
||||
running = true
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user