mirror of https://github.com/k3s-io/k3s
Merge pull request #14509 from mwielgus/spark-fix
E2E test - check pod.Status.Phase when greping through pod logspull/6/head
commit
1a47993f28
|
@ -562,22 +562,26 @@ func prepareResourceWithReplacedString(inputFile, old, new string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func forEachPod(c *client.Client, ns, selectorKey, selectorValue string, fn func(api.Pod)) {
|
func forEachPod(c *client.Client, ns, selectorKey, selectorValue string, fn func(api.Pod)) {
|
||||||
var pods *api.PodList
|
pods := []*api.Pod{}
|
||||||
var err error
|
|
||||||
for t := time.Now(); time.Since(t) < podListTimeout; time.Sleep(poll) {
|
for t := time.Now(); time.Since(t) < podListTimeout; time.Sleep(poll) {
|
||||||
pods, err = c.Pods(ns).List(labels.SelectorFromSet(labels.Set(map[string]string{selectorKey: selectorValue})), fields.Everything())
|
podList, err := c.Pods(ns).List(labels.SelectorFromSet(labels.Set(map[string]string{selectorKey: selectorValue})), fields.Everything())
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
if len(pods.Items) > 0 {
|
for _, pod := range podList.Items {
|
||||||
|
if pod.Status.Phase == api.PodPending || pod.Status.Phase == api.PodRunning {
|
||||||
|
pods = append(pods, &pod)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(pods) > 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pods == nil || len(pods.Items) == 0 {
|
if pods == nil || len(pods) == 0 {
|
||||||
Failf("No pods found")
|
Failf("No pods found")
|
||||||
}
|
}
|
||||||
for _, pod := range pods.Items {
|
for _, pod := range pods {
|
||||||
err = waitForPodRunningInNamespace(c, pod.Name, ns)
|
err := waitForPodRunningInNamespace(c, pod.Name, ns)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
fn(pod)
|
fn(*pod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue