mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #15813 from mesosphere/sttts-clusterdns-example
Auto commit by PR queue bot
This commit is contained in:
commit
0d7b53a201
@ -535,7 +535,13 @@ var _ = Describe("Examples e2e", func() {
|
||||
for _, ns := range namespaces {
|
||||
newKubectlCommand("create", "-f", "-", getNsCmdFlag(ns)).withStdinData(updatedPodYaml).exec()
|
||||
}
|
||||
// remember that we cannot wait for the pods to be running because our pods terminate by themselves.
|
||||
|
||||
// wait until the pods have been scheduler, i.e. are not Pending anymore. Remember
|
||||
// that we cannot wait for the pods to be running because our pods terminate by themselves.
|
||||
for _, ns := range namespaces {
|
||||
err := waitForPodNotPending(c, ns.Name, frontendPodName)
|
||||
expectNoError(err)
|
||||
}
|
||||
|
||||
// wait for pods to print their result
|
||||
for _, ns := range namespaces {
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/util/wait"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -30,7 +31,7 @@ import (
|
||||
var _ = Describe("kube-ui", func() {
|
||||
const (
|
||||
uiServiceName = "kube-ui"
|
||||
uiRcName = uiServiceName
|
||||
uiAppName = uiServiceName
|
||||
uiNamespace = api.NamespaceSystem
|
||||
|
||||
serverStartTimeout = 1 * time.Minute
|
||||
@ -44,7 +45,8 @@ var _ = Describe("kube-ui", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
By("Checking to make sure the kube-ui pods are running")
|
||||
err = waitForRCPodsRunning(f.Client, uiNamespace, uiRcName)
|
||||
selector := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": uiAppName}))
|
||||
err = waitForPodsWithLabelRunning(f.Client, uiNamespace, selector)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
By("Checking to make sure we get a response from the kube-ui.")
|
||||
|
@ -1525,15 +1525,29 @@ func ScaleRC(c *client.Client, ns, name string, size uint, wait bool) error {
|
||||
return waitForRCPodsRunning(c, ns, name)
|
||||
}
|
||||
|
||||
// Wait up to 10 minutes for pods to become Running.
|
||||
// Wait up to 10 minutes for pods to become Running. Assume that the pods of the
|
||||
// rc are labels with {"name":rcName}.
|
||||
func waitForRCPodsRunning(c *client.Client, ns, rcName string) error {
|
||||
selector := labels.SelectorFromSet(labels.Set(map[string]string{"name": rcName}))
|
||||
err := waitForPodsWithLabelRunning(c, ns, selector)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while waiting for replication controller %s pods to be running: %v", rcName, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Wait up to 10 minutes for all matching pods to become Running and at least one
|
||||
// matching pod exists.
|
||||
func waitForPodsWithLabelRunning(c *client.Client, ns string, label labels.Selector) error {
|
||||
running := false
|
||||
label := labels.SelectorFromSet(labels.Set(map[string]string{"name": rcName}))
|
||||
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
|
||||
}
|
||||
for _, p := range pods {
|
||||
if p.Status.Phase != api.PodRunning {
|
||||
continue waitLoop
|
||||
@ -1543,7 +1557,7 @@ waitLoop:
|
||||
break
|
||||
}
|
||||
if !running {
|
||||
return fmt.Errorf("Timeout while waiting for replication controller %s pods to be running", rcName)
|
||||
return fmt.Errorf("Timeout while waiting for pods with labels %q to be running", label.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user