use ctr content fetch and capture errors

This commit is contained in:
Benjamin Elder
2023-04-07 23:25:05 -07:00
parent 5a8ab4ad3e
commit bc2cacfed5
2 changed files with 6 additions and 14 deletions

View File

@@ -262,17 +262,11 @@ func (c *buildContext) prePullImagesAndWriteManifests(bits kube.Bits, parsedVers
image := image // https://golang.org/doc/faq#closures_and_goroutines
fns = append(fns, func() error {
if !builtImages.Has(image) {
/*
TODO: show errors when we have real errors. See comments in
importer implementation
err := importer.Pull(image, dockerBuildOsAndArch(c.arch))
if err != nil {
c.logger.Warnf("Failed to pull %s with error: %v", image, err)
runE := exec.RunErrorForError(err)
c.logger.Warn(string(runE.Output))
}
*/
_ = importer.Pull(image, dockerBuildOsAndArch(c.arch))
if err = importer.Pull(image, dockerBuildOsAndArch(c.arch)); err != nil {
c.logger.Warnf("Failed to pull %s with error: %v", image, err)
runE := exec.RunErrorForError(err)
c.logger.Warn(string(runE.Output))
}
}
return nil
})

View File

@@ -47,10 +47,8 @@ func (c *containerdImporter) End() error {
}
func (c *containerdImporter) Pull(image, platform string) error {
// TODO: this should exist with a --no-unpack and some way to operate quietly
// without discarding output
return c.containerCmder.Command(
"ctr", "--namespace=k8s.io", "images", "pull", "--platform="+platform, image,
"ctr", "--namespace=k8s.io", "content", "fetch", "--platform="+platform, image,
).SetStdout(ioutil.Discard).SetStderr(ioutil.Discard).Run()
}