Speed up DeleteRC test util func

This commit is contained in:
Wojciech Tyczynski 2016-03-07 17:53:49 +01:00
parent a914bbd0b8
commit ef0953585e

View File

@ -2319,10 +2319,12 @@ func DeleteRC(c *client.Client, ns, name string) error {
// waitForRCPodsGone waits until there are no pods reported under an RC's selector (because the pods // waitForRCPodsGone waits until there are no pods reported under an RC's selector (because the pods
// have completed termination). // have completed termination).
func waitForRCPodsGone(c *client.Client, rc *api.ReplicationController) error { func waitForRCPodsGone(c *client.Client, rc *api.ReplicationController) error {
labels := labels.SelectorFromSet(rc.Spec.Selector)
podStore := newPodStore(c, rc.Namespace, labels, fields.Everything())
defer podStore.Stop()
return wait.PollImmediate(poll, 2*time.Minute, func() (bool, error) { return wait.PollImmediate(poll, 2*time.Minute, func() (bool, error) {
selector := labels.SelectorFromSet(rc.Spec.Selector) if pods := podStore.List(); len(pods) == 0 {
options := api.ListOptions{LabelSelector: selector}
if pods, err := c.Pods(rc.Namespace).List(options); err == nil && len(pods.Items) == 0 {
return true, nil return true, nil
} }
return false, nil return false, nil