mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
retry image pulls once, fail if that doesn't work
This commit is contained in:
@@ -267,19 +267,23 @@ func (c *buildContext) prePullImagesAndWriteManifests(bits kube.Bits, parsedVers
|
||||
}()
|
||||
|
||||
fns := []func() error{}
|
||||
osArch := dockerBuildOsAndArch(c.arch)
|
||||
for _, image := range requiredImages {
|
||||
image := image // https://golang.org/doc/faq#closures_and_goroutines
|
||||
fns = append(fns, func() error {
|
||||
if !builtImages.Has(image) {
|
||||
if err = importer.Pull(image, dockerBuildOsAndArch(c.arch)); err != nil {
|
||||
fns = append(fns, func() error {
|
||||
if err = importer.Pull(image, osArch); err != nil {
|
||||
c.logger.Warnf("Failed to pull %s with error: %v", image, err)
|
||||
runE := exec.RunErrorForError(err)
|
||||
c.logger.Warn(string(runE.Output))
|
||||
}
|
||||
c.logger.Warnf("Retrying %s pull after 1s ...", image)
|
||||
time.Sleep(time.Second)
|
||||
return importer.Pull(image, osArch)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}
|
||||
if err := errors.AggregateConcurrent(fns); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user