Retry image pulling 5 times before giving up in node e2e.

Signed-off-by: Vishnu kannan <vishnuk@google.com>
pull/6/head
Vishnu kannan 2016-05-25 16:37:04 -07:00
parent 69b90028cf
commit 2be9cd4854
1 changed files with 18 additions and 3 deletions

View File

@ -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