This is a sub-issue of #1376 and goes a small way to supporting the functionality described there. This issue is focused solely on running Steps inside a Task when prior steps (within the same Task) have failed. This issue specifically does not deal with running whole Tasks when previous Tasks have failed.
1) A unit test step fails but a subsequent step in the same Task should upload the results to a bucket regardless of that failure.
2) A Pull Request pipeline resource should update a PR with a comment reflecting the status of a failed build. The build happens in one step and then the PR resource could inject a step at the end which runs regardless of the error and knows how to update github/gitlab/etc with the status comment.
There currently isn't support for running a subsequent Step if a prior one has already failed in the same Task.
Add a field to the Step type that is named something like ignorePreviousStepErrors. It defaults to false. Setting this field to true will tell that Step to run regardless of whether prior steps in the same Task failed.
Example YAML:
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
generateName: test-and-upload-to-gcs-
spec:
taskSpec:
steps:
- name: test
image: node-run-tests
command: ['npm']
args: ['run', 'tests']
- name: publish-npm-package
image: node-publish-package
command: ['npm']
args: ['run', 'tests']
- name: upload-test-results
ignorePreviousStepErrors: true
image: upload-test-results
command: ['gsutil']
args: ['cp', '/workspace/test-results.xml', 'gs://mybucket/test-results.xml']
- name: deploy-to-prod
image: deploy-image
command: deploy
How would this example execute?
node-run-tests step would execute.publish-npm-package would be skipped. This is the behaviour we currently enforce with Tekton.upload-test-results includes the ignorePreviousStepErrors field and has it set to true. Therefore this step is executed regardless of the failure in the first step.deploy-to-prod does not run because a prior step has failed.ignorePreviousStepErrors: true would be allowed to run.The TaskRun would end with a Failed status, since one of its steps ended with an error, but the step to upload test results would be allowed to run regardless.
/kind feature
Related issue: https://github.com/tektoncd/pipeline/issues/1376
Presented during working group today. Feedback I can remember from the meeting:
It seems to me there are two specific levers that a user might want to be able to pull in relation to this feature:
ignorePrevStepErrors:true/falseentrypointStrategy: IgnorePreviousStepErrorsentrypointStrategy to the Task itself as a mechanism to provide the default strategy for each StepI put up a design doc that for an alternative that's aligned with #2437:
https://docs.google.com/document/d/1e1fagYDErliLnIwU1g_N3YKVyAProhs1l14UyPIoZuM/edit?usp=sharing
Let me add another use case here:
I have a pipeline where I want to:
I want the tear down task to run regardless of whether tests passed or failed.
@gsaslis This sounds like a use case for a Pipeline comprised of reusable single-purpose Tasks, rather than a single Task which is responsible for doing everything at once. In this case, your Pipeline would have Tasks for each bullet point (provision, deploy, integration-test, teardown), and the ongoing Pipeline-level finally work (#2437) should be useful to you.
By putting this logic into a single Task, you make it less reusable, and since steps within a Task are executed sequentially, you lose out on the option to, for instance, to multiple locations concurrently.
@ImJasonH thanks for the pointer. I absolutely meant for those to be separate Tasks (which is why i referred to it as a "task" above.
What I didn't notice was the big, fat "within the same Task" on this issue title 🤕
Yes, this use case was not meant for this particular task - I just found this one first. Apologies for the noise.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
/close
Send feedback to tektoncd/plumbing.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
/lifecycle rotten
Send feedback to tektoncd/plumbing.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Send feedback to tektoncd/plumbing.
@tekton-robot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten./close
Send feedback to tektoncd/plumbing.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Reopening as this is still discussed with some regularity during API WGs and on Slack.
/reopen
/remove-lifecycle stale
/remove-lifecycle rotten
@sbwsg: Reopened this issue.
In response to this:
Reopening as this is still discussed with some regularity during API WGs and on Slack.
/reopen
/remove-lifecycle stale
/remove-lifecycle rotten
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Send feedback to tektoncd/plumbing.
/remove-lifecycle stale
Most helpful comment
(i) suggesting we do something a bit more flexible like instead of...
ignorePrevStepErrors:true/falseDo something like...
entrypointStrategy: IgnorePreviousStepErrors(ii) If we're feeling ambitious we can add an
entrypointStrategyto the Task itself as a mechanism to provide the default strategy for each Step