Skip to content

Commit

Permalink
Don't fail immediatley if a fixup fails
Browse files Browse the repository at this point in the history
When applying fixups to an image, accumulate any errors and only return an error if
the image ultimately was unable to be pushed.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
  • Loading branch information
carolynvs committed Apr 14, 2022
1 parent 4a906b8 commit b9df3a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions remotes/fixup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/remotes"
"github.com/docker/distribution/reference"
"github.com/hashicorp/go-multierror"
ocischemav1 "github.com/opencontainers/image-spec/specs-go/v1"
)

Expand Down Expand Up @@ -216,18 +217,20 @@ func fixupBaseImage(ctx context.Context, name string, baseImage *bundle.BaseImag
pushLocalImage,
}

var bigErr *multierror.Error
for _, f := range fixups {
info, pushed, ok, err := f(ctx, targetRepoOnly, baseImage, cfg)
if err != nil {
log.G(ctx).Debug(err)
return imageFixupInfo{}, false, fmt.Errorf("failed to fixup the image %s for service %q: %v", baseImage.Image, name, err)
// do not stop trying fixups after the first error. Only report the errors if all fixups were unable to push the image.
bigErr = multierror.Append(bigErr, fmt.Errorf("failed to fixup the image %s for service %q: %v", baseImage.Image, name, err))
}
if ok {
return info, pushed, nil
}
}

return imageFixupInfo{}, false, fmt.Errorf("failed to resolve or push image %s for service %q", baseImage.Image, name)
return imageFixupInfo{}, false, bigErr.ErrorOrNil()
}

func pushByDigest(ctx context.Context, target reference.Named, baseImage *bundle.BaseImage, cfg fixupConfig) (imageFixupInfo, bool, bool, error) {
Expand Down

0 comments on commit b9df3a4

Please sign in to comment.