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

Surface error results to BuildRun #930

Merged

Conversation

dalbar
Copy link
Member

@dalbar dalbar commented Nov 2, 2021

Changes

This PR provides a mechanism to surface errors in the build process into BuildRun objects granting more visibility into without being Tekton/Implementation specific. To achieve this goal, we introduce two new generic results shp-error-reason and shp-error-message, that a TaskRun can emit and a BuildRun can pick up.

Initial implementation for ship 24.

/kind feature
/kind api-change

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing (docs will be included once the linked ship progresses)
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

Release Note

Added a new field `FailureDetails` to BuildRun's `Status` that has the failure location of a failed build pod and container. Additionally the new field contains a `Reason` and `Message` to communicate error information to users and third parties. 

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Label for when a PR has specified a release note kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Nov 2, 2021
@dalbar
Copy link
Member Author

dalbar commented Nov 2, 2021

Continuation of #901.

As requested by @adambkaplan, I have split the error surfacing logic from the git error reporting.

@dalbar dalbar force-pushed the add/surface_error_results branch from 5a6317c to 07f0af5 Compare November 2, 2021 10:50
@dalbar
Copy link
Member Author

dalbar commented Nov 2, 2021

recreating the reviewer list from previous PR:

/unassign @qu1queee
/unassign @shahulsonhal
/assign @SaschaSchwarze0
/assign @adambkaplan
/assign @coreydaley
/assign @otaviof

Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Nice work. Please also extend the buildstrategy.md. Give some guidance on how the two results can be filled - and important: to fail the buildrun, the step still must return a non-zero exit code. We can add examples in later PRs into our sample build strategies.

@dalbar dalbar force-pushed the add/surface_error_results branch 2 times, most recently from b9475f3 to 98399e3 Compare November 3, 2021 10:19
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 3, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2021
docs/buildrun.md Outdated Show resolved Hide resolved
docs/buildstrategies.md Outdated Show resolved Hide resolved
@dalbar dalbar force-pushed the add/surface_error_results branch 2 times, most recently from c743d21 to 51a348e Compare November 3, 2021 20:43
@dalbar dalbar requested a review from gabemontero November 3, 2021 20:44
@gabemontero
Copy link
Member

my 2 comments / suggestions have been addressed - thanks @dalbar

@otaviof @adambkaplan @coreydaley - as being assigned to this PR, do you all want to take a review at this before it gets the lgtm tag? If so, please do so. If not, unassign yourselves and we'll from there (I might be able to take a more detailed pass before my EOB today).

thanks

@coreydaley coreydaley removed their assignment Nov 5, 2021
Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

Most of my comments here are stylistic recommendations. Since build results are effectively "user generated," I recommend that we establish a convention for the provided reason in our documentation and code.

docs/buildrun.md Outdated Show resolved Hide resolved
docs/buildstrategies.md Outdated Show resolved Hide resolved
docs/buildstrategies.md Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/failureDetails_test.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/failureDetails_test.go Outdated Show resolved Hide resolved
Comment on lines 20 to 25
const (
resultErrorMessage = "error-message"
resultErrorReason = "error-reason"
prefixedResultErrorReason = prefixParamsResultsVolumes + "-" + resultErrorReason
prefixedResultErrorMessage = prefixParamsResultsVolumes + "-" + resultErrorMessage
)
Copy link
Member

Choose a reason for hiding this comment

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

These constants should be moved to pkg/apis/build/v1alpha1

Copy link
Member Author

@dalbar dalbar Nov 13, 2021

Choose a reason for hiding this comment

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

What is your reasoning for that? It is currently only used in the resources package.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to Baran's assessment. The constants are an implementation detail because we use them on the TaskRun internally but in the BuildRun they are copied into "normal" fields in the status. -> Somebody who uses our Go types does not need to know these constants.

pkg/reconciler/buildrun/resources/failureDetails_test.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/failureDetails.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/conditions.go Outdated Show resolved Hide resolved
pkg/reconciler/buildrun/resources/conditions.go Outdated Show resolved Hide resolved
@dalbar dalbar force-pushed the add/surface_error_results branch 3 times, most recently from d67c464 to f5c483f Compare November 13, 2021 17:17
@dalbar dalbar force-pushed the add/surface_error_results branch from f5c483f to 595e7d0 Compare November 13, 2021 17:28
@dalbar dalbar force-pushed the add/surface_error_results branch from 595e7d0 to 0add676 Compare November 15, 2021 11:18
@dalbar dalbar force-pushed the add/surface_error_results branch from 0add676 to da542ee Compare November 23, 2021 22:38
@dalbar dalbar force-pushed the add/surface_error_results branch 4 times, most recently from 4d9505d to 495654b Compare December 7, 2021 09:03
@HeavyWombat HeavyWombat self-requested a review December 10, 2021 08:39
Copy link
Member

@adambkaplan adambkaplan left a comment

Choose a reason for hiding this comment

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

@dalbar generally looks good - please squash your commits and then I think we can lgtm this.

@dalbar dalbar force-pushed the add/surface_error_results branch from 495654b to 819300f Compare December 13, 2021 19:44
@dalbar
Copy link
Member Author

dalbar commented Dec 13, 2021

@dalbar generally looks good - please squash your commits and then I think we can lgtm this.

Thanks. I have squashed the commits.

@HeavyWombat
Copy link
Contributor

@dalbar Have you seen these verify remarks:

The pkg/client, pkg/apis package or CRDs contains changes:
deploy/crds/shipwright.io_buildruns.yaml

make: *** [Makefile:115: verify-generate] Error 1
Run make generate to those commit changes!

Can you run a make generate locally?

@dalbar dalbar force-pushed the add/surface_error_results branch 2 times, most recently from d189b90 to 3ef1606 Compare December 13, 2021 20:57
@dalbar
Copy link
Member Author

dalbar commented Dec 13, 2021

@dalbar Have you seen these verify remarks:

The pkg/client, pkg/apis package or CRDs contains changes:
deploy/crds/shipwright.io_buildruns.yaml

make: *** [Makefile:115: verify-generate] Error 1
Run make generate to those commit changes!

Can you run a make generate locally?

I did and the command did not yield any changes.

@shahulsonhal
Copy link
Member

@dalbar Have you seen these verify remarks:

The pkg/client, pkg/apis package or CRDs contains changes:
deploy/crds/shipwright.io_buildruns.yaml

make: *** [Makefile:115: verify-generate] Error 1
Run make generate to those commit changes!

Can you run a make generate locally?

I did and the command did not yield any changes.

@dalbar, Please try the following steps:

  1. Rebase with the main branch
  2. Run make generate (may fail in the first run and ask you to update controller-gen version)
  3. Update the controller gen version (go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2)
  4. Run make generate again

According to ship 0024, this commit adds a mechanism to surface errors
from TaskRun steps. The errors are published under `status.failure` in
BuildRun iff underlying TaskRun has failed.
@dalbar dalbar force-pushed the add/surface_error_results branch from 3ef1606 to 3a2e93d Compare December 14, 2021 06:15
@dalbar dalbar requested a review from adambkaplan December 14, 2021 08:50
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.8.0 milestone Jan 3, 2022
@SaschaSchwarze0
Copy link
Member

The remaining TODOs (squashing commits and running make generate again) had been performed. Adding lgtm

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 3, 2022
@openshift-merge-robot openshift-merge-robot merged commit e558e14 into shipwright-io:main Jan 3, 2022
@dalbar dalbar deleted the add/surface_error_results branch February 26, 2022 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants