From 2be9cd4854acd89eae392411d4ba2de7ff528856 Mon Sep 17 00:00:00 2001 From: Vishnu kannan Date: Wed, 25 May 2016 16:37:04 -0700 Subject: [PATCH] Retry image pulling 5 times before giving up in node e2e. Signed-off-by: Vishnu kannan --- test/e2e_node/container_list.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/e2e_node/container_list.go b/test/e2e_node/container_list.go index d252ae526b9..1afd2130435 100644 --- a/test/e2e_node/container_list.go +++ b/test/e2e_node/container_list.go @@ -17,12 +17,18 @@ limitations under the License. package e2e_node import ( - "github.com/golang/glog" "os/exec" + "time" + + "github.com/golang/glog" ) const ( - busyBoxImage = iota + // Number of attempts to pull an image. + maxImagePullRetries = 5 + // Sleep duration between image pull retry attempts. + imagePullRetryDelay = time.Second + busyBoxImage = iota hostExecImage netExecImage @@ -51,7 +57,16 @@ var NoPullImagRegistry = map[int]string{ // Pre-fetch all images tests depend on so that we don't fail in an actual test func PrePullAllImages() error { for _, image := range ImageRegistry { - output, err := exec.Command("docker", "pull", image).CombinedOutput() + var ( + err error + output []byte + ) + for i := maxImagePullRetries; i > 0; i++ { + if output, err = exec.Command("docker", "pull", image).CombinedOutput(); err == nil { + break + } + time.Sleep(imagePullRetryDelay) + } if err != nil { glog.Warningf("Could not pre-pull image %s %v output: %s", image, err, output) return err