pipeline: Publish results when task and pipeline runs fail
Feature request
Results should be available for failed task and pipeline runs.
Today, if a TaskRun or PipelineRun is set to failed, we skip the code that grabs the results and adds them to status.
Use case
Results can be used by a failing task or pipeline to provide more context about why the failed, or how to react to the failure.
One specific use case that I’m trying to implement, is to enrich the GitHub update pipelines in Tekton based CI with the ability to publish a comment that gives the developer more context about the failure. Today that can achieved by adding that comment into the logs, however a comment on GitHub provides a more immediate feedback to developers. Specifically I’d like to improve the job that checks for the “kind label”.
That would work as follow:
- the CI
TaskRunis executed. - if no valid label is found, a message with the list of valid labels is published to a specific result
- the
TaskRunfails - a cloud event is sent to the
tekton-eventstrigger. In includes theTaskRunstatus in the payload - the trigger filters the event
- a binding extracts the result from the payload and passes it the trigger template
- the trigger template runs the github update pipeline, which sets the status and adds the comment
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 28 (12 by maintainers)
Commits related to this issue
- Fix the check labels job The check labels job uses the PR pipeline resource to add a comment to the PR with instructions for developers in case of failure. That doesn't work though because in case of... — committed to afrittoli/plumbing by afrittoli 3 years ago
- Fix the check labels job The check labels job uses the PR pipeline resource to add a comment to the PR with instructions for developers in case of failure. That doesn't work though because in case of... — committed to tektoncd/plumbing by afrittoli 3 years ago
- Publish Pipeline Results from successful TaskRuns in Failed PipelineRuns Publish Pipeline Results from successful TaskRuns in Failed PipelineRuns: #3749 Prior to this change a failed PipelineRun doe... — committed to QuanZhang-William/pipeline by QuanZhang-William 2 years ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to Yongxuanzhang/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to tektoncd/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to tekton-robot/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to yyzxw/pipeline by Yongxuanzhang a year ago
- don't return validation error when taskrun failed/skipped This commit aims to fix #6383, #6139 and supports #3749. This commits skip the validation if the taskrun is not successful (e.g. failed or sk... — committed to tektoncd/pipeline by Yongxuanzhang a year ago
I have a pretty basic use case for this @pritidesai and It seems like a pretty big oversight from where I am sitting!
Right now I have to jump through hoops and upload/download my results with an external repo because I can’t rely on results on a failed job.
I want my “bot” to post a summary back especially if something failed, so that the end user knows why they failed.
Hey @lcarva We do not have a test/example to support the use of task results from a failed task in pipeline results. At least I can not recollect seeing it and remember that as something pending.
/remove-lifecycle stale
It would make sense to at least allow publishing pipeline results that are not depending on results of a failing task, the minimal reproducer is below. In my real-world use-case, I have a pipeline with task A publishing a result, task B using task A’s result, pipeline publishes a result based on task A result. When task A succeeds and task B fails, pipeline doesn’t publish result.
Gotcha, Producing task result with onError might actually do the trick
I was re-reading the whole thread, and I think there are three different things describe in the thread:
Implementing (2) alone would solve @ppitonak issue and would be easy to implement. We could include a fixed string (i.e. NOT_AVAILABLE) in results that are not available, but if we did that we would need then to user no breaking changes on it.
Yes, indeed.
The status will stay in etcd, might be gobbled up by chains, stored in results, sent over cloud events, trigger other parts of the workflow, so there is value in having that result even if it won’t be read by other tasks.
It may also be used by tasks in finally, once the corresponding TEP is implemented.
I didn’t think in terms of error results before, I kind of expected results to be there in case of failure too, and I’m not sure why they are not. In case of a task failure we should provide as much context as available - why skip results then? I was tempted to file this as bug, but I created it as a feature because the code explicitly skips results in case of failure.
Optional results are certainly an interesting topic, this TEP is related: https://github.com/tektoncd/community/pull/240. Default values for results may address some case but not when the result value needs to be produced by a step.