Add retries to GetPod calls. (#1420)

pull/1423/head
dlorenc 2017-04-26 16:53:41 -07:00 committed by GitHub
parent e37c87ae4f
commit c9bb006283
4 changed files with 16 additions and 8 deletions

View File

@ -47,7 +47,11 @@ func testClusterDNS(t *testing.T) {
p := &api.Pod{}
for p.Status.Phase != "Running" {
p = kubectlRunner.GetPod(podName, podNamespace)
var err error
p, err = kubectlRunner.GetPod(podName, podNamespace)
if err != nil {
return &commonutil.RetriableError{Err: err}
}
}
dnsByteArr, err := kubectlRunner.RunCommand([]string{"exec", podName, "--namespace=" + podNamespace,

View File

@ -70,7 +70,10 @@ func testMounting(t *testing.T) {
p := &api.Pod{}
for p.Status.Phase != "Running" {
p = kubectlRunner.GetPod(podName, "default")
p, err = kubectlRunner.GetPod(podName, "default")
if err != nil {
return &commonutil.RetriableError{Err: err}
}
}
path := filepath.Join(tempDir, "frompod")

View File

@ -47,7 +47,10 @@ func TestPersistence(t *testing.T) {
}
checkPod := func() error {
p := kubectlRunner.GetPod(podName, podNamespace)
p, err := kubectlRunner.GetPod(podName, podNamespace)
if err != nil {
return &commonutil.RetriableError{Err: err}
}
if kubectlRunner.IsPodReady(p) {
return nil
}

View File

@ -202,10 +202,8 @@ func (k *KubectlRunner) DeleteNamespace(namespace string) error {
return err
}
func (k *KubectlRunner) GetPod(name, namespace string) *api.Pod {
func (k *KubectlRunner) GetPod(name, namespace string) (*api.Pod, error) {
p := &api.Pod{}
if err := k.RunCommandParseOutput([]string{"get", "pod", name, "--namespace=" + namespace}, p); err != nil {
k.T.Fatalf("Error checking pod status: %s", err)
}
return p
err := k.RunCommandParseOutput([]string{"get", "pod", name, "--namespace=" + namespace}, p)
return p, err
}