retry image pulls once, fail if that doesn't work

This commit is contained in:
Benjamin Elder
2025-01-22 15:03:15 -08:00
parent d66a745392
commit b594068ca9

View File

@@ -267,18 +267,22 @@ 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 {
if !builtImages.Has(image) {
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
})
return nil
})
}
}
if err := errors.AggregateConcurrent(fns); err != nil {
return nil, err