pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

Exiting pipeline with success on step error

Open msvticket opened this issue 3 years ago • 11 comments

Feature request

I would like support for a new value of the onError field on steps with the meaning that the pipeline exits as succeeded. The value could maybe be stopAndSucceed.

Use case

The use case I have currently is that I have pipelines with steps for build, deploy and integrations tests. Between these steps I have a step checking if a newer build has started and in that case the step exits with an error. This is to prevent concurrent deploys and tests. But if a pipeline run is exiting due to the existence of a newer one that isn't a failure and I don't really want it to be reported as such.

msvticket avatar Jan 14 '22 11:01 msvticket

thank you @msvticket for this!

I am trying to understand your use case, is the step which checks if a newer build has started, exiting with an error? In your case, you want to exit the pipeline as success without running any subsequent step/task when that step discovers a newer build. Is that correct?

We have two values supported so far, continue and stopAndFail for onError.

continue: ignore the step error and continue executing rest of the steps in that task and rest of the tasks in a pipeline. stopAndFail: stop executing anything further and exit with an error stopAndSucceed: stop executing anything further but exit with success?

pritidesai avatar Jan 14 '22 19:01 pritidesai

Yes, exactly!

As far as I know the only way for a step to prevent the subsequent steps of a task to be executed is to exit with an error. But in this case it's not actually due to a failure, so it's not really truthful when the PipelineRun get a conditions list like this:

  conditions:
  - lastTransitionTime: "2022-01-14T11:07:10Z"
    message: 'Tasks Completed: 1 (Failed: 1, Cancelled 0), Skipped: 0'
    reason: Failed
    status: "False"
    type: Succeeded

In my specific case notification of a failure like this would be made through Slack. With tekton in this case crying wolf there would be a risk of real errors being neglected.

I can also see the need for support of a value like continueAndFail for onError. This would mean: continue executing the rest of the steps in the task but exit the task with an error (and thus don't execute the rest of the tasks in the pipeline). I suspect this should be another issue, but if you want I could elaborate on the use case in this issue.

msvticket avatar Jan 14 '22 23:01 msvticket

thank you @msvticket, I will bring this up in the next API WG (2/7) to collect feedback from the community 🙏

pritidesai avatar Jan 31 '22 19:01 pritidesai

Hey @msvticket - is your preference to have this within a Task or a Pipeline? i.e. do you have one task with all of the elements you mentioned: build, deploy and integrations tests, or is each of these a Task which you combine together into a Pipeline?

If it could work for you to implement this at the level of a Task within a Pipeline (vs a step within a Task), that would be my preference - it would allow folks to reuse tasks (e.g. from the catalog) and control whether they want to fail when they fail or not within the Pipeline without needing to edit the tasks at all

@pritidesai had previously started a TEP which starts to address this use case (https://github.com/tektoncd/community/blob/main/teps/0050-ignore-task-failures.md )

bobcatfish avatar Feb 02 '22 19:02 bobcatfish

This story is about steps in a task and that is how I prefer to have it. Also in Jenkins-X there is a mechanism to reuse steps from a task from a catalogue in another task, so for me that isn't opposed to reuse.

msvticket avatar Feb 04 '22 09:02 msvticket

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. 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 with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar May 05 '22 10:05 tekton-robot

This is still a needed feature.

/remove-lifecycle stale

msvticket avatar May 24 '22 22:05 msvticket

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. 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 with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Aug 22 '22 23:08 tekton-robot

/remove-lifecycle stale

msvticket avatar Aug 31 '22 08:08 msvticket

@pritidesai I have to admit I don't understand the process here. I can not see how this can be seen as other than a simple addition to the API that is in line with the current functionality.

I can probably device a pull request with the functionality. But I don't want to spend time on that if the PR wont be accepted.

msvticket avatar Nov 03 '22 16:11 msvticket

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. 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 with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Feb 01 '23 17:02 tekton-robot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten with a justification. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

tekton-robot avatar Mar 03 '23 17:03 tekton-robot

I am pasting the meeting notes here from the discussion on 2022/02/07:

[onError](https://github.com/tektoncd/pipeline/blob/main/docs/tasks.md#specifying-onerror-for-a-step) - stopAndSucceed - adding a new option to stop and succeed
https://github.com/tektoncd/pipeline/issues/4485 
continue: ignore the step error and continue executing the rest of the steps in that task and rest of the tasks in a pipeline.
stopAndFail: stop executing anything further and exit with an error
stopAndSucceed: stop executing anything further but exit with success? 
(Christie) wondering if we need this at the Task step level or if doing this at the pipeline level might be a better first option ([TEP-0050](https://github.com/tektoncd/community/blob/main/teps/0050-ignore-task-failures.md))
When expressions at the step level - "skip some steps"
The particular use case mentioned by the user might be addressed concurrency controller
another option: restructure pipeline to use tasks instead of steps within a task

This feature has not been addressed yet and we haven't gotten an alternative as well therefore opening this issue.

@msvticket let me know if you are still interested in this feature and would like to collaborate. Thanks!

/remove-lifecycle rotten

pritidesai avatar Mar 03 '23 17:03 pritidesai

I'm certainly both still interested and open for collaboration.

msvticket avatar Mar 09 '23 10:03 msvticket

Hi do we have any update on this?

lavu1911 avatar May 31 '23 10:05 lavu1911

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. 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 with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Aug 29 '23 11:08 tekton-robot

@pritidesai So what should I do to get this solved?

/remove-lifecycle stale

msvticket avatar Aug 29 '23 12:08 msvticket