Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return more detailed errors when fixup fails #113

Merged
merged 3 commits into from
Jul 6, 2022

Conversation

carolynvs
Copy link
Collaborator

It's not possible from the current error to tell what went wrong since the real error is only sent to the debug logger, and isn't included in the returned error message.

I have updated the errors returned from each fixup function so that you can tell where the fixup failed from the error message.

❓ There is still one message that I didn't know how to improve. If all the fixups complete, but nothing was pushed, then when we finish iterating over the fixups, a generic error is returned. I'm not sure what would cause that situation so I kept the error message as-is, but when you run into that error, it's too vague to help narrow down the problem.

remotes/fixup.go Outdated
}
if ok {
return info, pushed, nil
}
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one error message that I'm not clear on how we actually get into this situation and what else we could include in the message to help someone solve the problem.

@carolynvs carolynvs marked this pull request as ready for review November 8, 2021 18:07
carolynvs added a commit to carolynvs/porter that referenced this pull request Nov 9, 2021
When cnab-to-oci fixes up a bundle after publishing it, if any error
occurs we only get a single error message

"failed to fixup the image for service InvocationImage"

This bumps our cnab-to-oci to use the patch in

cnabio/cnab-to-oci#113

so that we get a more detailed error message that indicates the image
that failed, and which fixup step.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
carolynvs added a commit to carolynvs/porter that referenced this pull request Nov 9, 2021
When cnab-to-oci fixes up a bundle after publishing it, if any error
occurs we only get a single error message

"failed to fixup the image for service InvocationImage"

This bumps our cnab-to-oci to use the patch in

cnabio/cnab-to-oci#113

so that we get a more detailed error message that indicates the image
that failed, and which fixup step.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
remotes/fixup.go Outdated
@@ -220,59 +220,69 @@ func fixupBaseImage(ctx context.Context, name string, baseImage *bundle.BaseImag
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read this correctly, this returns early if there is an error pushing any image. Is this the intended behavior? Do we want to keep pushing and then return an error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly it's super hard to follow the logic for how the fixups should be applied. Can you help clarify so that I can better match the desired behavior here?

It looks like as soon as one fixup returns "ok=true" (not sure what ok indicates though), then we stop applying fixups. Is it expected that a fixup will fail with an error and we should keep trying other fixups?

I could instead keep a multierror and only return it when none of the fixups return ok (i.e. in that final return statement with the ambiguous error). What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radu-matei Any thoughts on my question above?

Copy link
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with one question about returning early.

It's not possible from the current error to tell what went wrong since
the real error is only sent to the debug logger, and isn't included in
the returned error message.

I have updated the errors returned from each fixup function so that you
can tell where the fixup failed from the error message.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
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>
@carolynvs carolynvs merged commit c911a15 into cnabio:main Jul 6, 2022
@carolynvs carolynvs deleted the return-copy-error branch July 6, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants