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

configure a task to run after 1 or more conditional tasks #2937

Closed
prantaa opened this issue Jul 14, 2020 · 10 comments
Closed

configure a task to run after 1 or more conditional tasks #2937

prantaa opened this issue Jul 14, 2020 · 10 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@prantaa
Copy link

prantaa commented Jul 14, 2020

Feature request

To be able to configure a task to run after 1 or more conditional tasks.

Use case

I'm trying to create the following pipeline:

Task(git clone repo) -> Task(run tests) -> Task(create git issue if tests failed) -> Task(Send out slack notification)

The create git issue task is conditional based on the results of the tests that were run previously.

I'd like to be able to run the last slack notification task after either the create git issue task completed or if it was not run due to condition (the slack message is dynamically created based on execution flow).

@prantaa prantaa added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 14, 2020
@jerop
Copy link
Member

jerop commented Jul 14, 2020

@prantaa we're designing solutions to address the issues in Conditions, including providing more options upon Condition failure -- please see the Failure Handling sections of this design doc and share any feedback you may have

jerop added a commit to jerop/pipeline that referenced this issue Jul 22, 2020
When a `Condition` fails, the guarded `Task` and its branch
(dependent `Tasks`) are skipped. A `Task` is dependent on and in the
branch of another `Task` as specified by ordering using `runAfter` or by
resources using `Results`, `Workspaces` and `Resources`.

In some use cases of `Conditions`, when a `Condition` evaluates to
`False`, users need to skip the guarded `Task` only and allow dependent
`Tasks` to execute. An example use case is when there’s a particular
`Task` that a Pipeline wants to execute when the git branch is
dev/staging/qa, but not when it’s the main/master/prod branch.
Another use case is when a user wants to send out a notification whether
or not a parent guarded `Task` was executed, as described in
[this issue](tektoncd#2937).

In this PR, we add a `continueAfterSkip` field to specify whether to
terminate the whole `Task` branch, or to skip the guarded `Task` only
and continue with the rest of the `Task` branch.

When a `Condition` evaluates to `False`, to skip the guarded `Task`
only and allow dependent `Tasks` to execute, users can pass in the
`continueAfterSkip` field and set it to `true` or `yes` (case insensitive).
The field defaults to `false` -- the rest of the `Task` branch is skipped
by default as it was previously.
I
When `continueAfterSkip` is set to `True`, subsequent `Tasks` based on
ordering dependencies should execute and the subsequent `Tasks` based
resource dependencies will have resource validation errors.
jerop added a commit to jerop/pipeline that referenced this issue Jul 22, 2020
When a `Condition` fails, the guarded `Task` and its branch
(dependent `Tasks`) are skipped. A `Task` is dependent on and in the
branch of another `Task` as specified by ordering using `runAfter` or by
resources using `Results`, `Workspaces` and `Resources`.

In some use cases of `Conditions`, when a `Condition` evaluates to
`False`, users need to skip the guarded `Task` only and allow dependent
`Tasks` to execute. An example use case is when there’s a particular
`Task` that a Pipeline wants to execute when the git branch is
dev/staging/qa, but not when it’s the main/master/prod branch.
Another use case is when a user wants to send out a notification whether
or not a parent guarded `Task` was executed, as described in
[this issue](tektoncd#2937).

In this PR, we add a `continueAfterSkip` field to specify whether to
terminate the whole `Task` branch, or to skip the guarded `Task` only
and continue with the rest of the `Task` branch.

When a `Condition` evaluates to `False`, to skip the guarded `Task`
only and allow dependent `Tasks` to execute, users can pass in the
`continueAfterSkip` field and set it to `true` or `yes` (case insensitive).
The field defaults to `false` -- the rest of the `Task` branch is skipped
by default as it was previously.

When `continueAfterSkip` is set to `True`, subsequent `Tasks` based on
ordering dependencies should execute and the subsequent `Tasks` based
resource dependencies will have resource validation errors.
@jerop jerop mentioned this issue Jul 23, 2020
4 tasks
jerop added a commit to jerop/pipeline that referenced this issue Jul 23, 2020
When a `Condition` fails, the guarded `Task` and its branch
(dependent `Tasks`) are skipped. A `Task` is dependent on and in the
branch of another `Task` as specified by ordering using `runAfter` or by
resources using `Results`, `Workspaces` and `Resources`.

In some use cases of `Conditions`, when a `Condition` evaluates to
`False`, users need to skip the guarded `Task` only and allow dependent
`Tasks` to execute. An example use case is when there’s a particular
`Task` that a Pipeline wants to execute when the git branch is
dev/staging/qa, but not when it’s the main/master/prod branch.
Another use case is when a user wants to send out a notification whether
or not a parent guarded `Task` was executed, as described in
[this issue](tektoncd#2937).

In this PR, we add a `continueAfterSkip` field to specify whether to
terminate the whole `Task` branch, or to skip the guarded `Task` only
and continue with the rest of the `Task` branch.

When a `Condition` evaluates to `False`, to skip the guarded `Task`
only and allow dependent `Tasks` to execute, users can pass in the
`continueAfterSkip` field and set it to `true` or `yes` (case insensitive).
The field defaults to `false` -- the rest of the `Task` branch is skipped
by default as it was previously.

When `continueAfterSkip` is set to `True`, subsequent `Tasks` based on
ordering dependencies should execute and the subsequent `Tasks` based
resource dependencies will have resource validation errors.
jerop added a commit to jerop/pipeline that referenced this issue Jul 23, 2020
When a `Condition` fails, the guarded `Task` and its branch
(dependent `Tasks`) are skipped. A `Task` is dependent on and in the
branch of another `Task` as specified by ordering using `runAfter` or by
resources using `Results`, `Workspaces` and `Resources`.

In some use cases of `Conditions`, when a `Condition` evaluates to
`False`, users need to skip the guarded `Task` only and allow dependent
`Tasks` to execute. An example use case is when there’s a particular
`Task` that a Pipeline wants to execute when the git branch is
dev/staging/qa, but not when it’s the main/master/prod branch.
Another use case is when a user wants to send out a notification whether
or not a parent guarded `Task` was executed, as described in
[this issue](tektoncd#2937).

In this PR, we add a `continueAfterSkip` field to specify whether to
terminate the whole `Task` branch, or to skip the guarded `Task` only
and continue with the rest of the `Task` branch.

When a `Condition` evaluates to `False`, to skip the guarded `Task`
only and allow dependent `Tasks` to execute, users can pass in the
`continueAfterSkip` field and set it to `true` or `yes` (case insensitive).
The field defaults to `false` -- the rest of the `Task` branch is skipped
by default as it was previously.

When `continueAfterSkip` is set to `True`, subsequent `Tasks` based on
ordering dependencies should execute and the subsequent `Tasks` based
resource dependencies will have resource validation errors.
jerop added a commit to jerop/pipeline that referenced this issue Jul 28, 2020
When a `Condition` fails, the guarded `Task` and its branch
(dependent `Tasks`) are skipped. A `Task` is dependent on and in the
branch of another `Task` as specified by ordering using `runAfter` or by
resources using `Results`, `Workspaces` and `Resources`.

In some use cases of `Conditions`, when a `Condition` evaluates to
`False`, users need to skip the guarded `Task` only and allow dependent
`Tasks` to execute. An example use case is when there’s a particular
`Task` that a Pipeline wants to execute when the git branch is
dev/staging/qa, but not when it’s the main/master/prod branch.
Another use case is when a user wants to send out a notification whether
or not a parent guarded `Task` was executed, as described in
[this issue](tektoncd#2937).

In this PR, we add a `continueAfterSkip` field to specify whether to
terminate the whole `Task` branch, or to skip the guarded `Task` only
and continue with the rest of the `Task` branch.

When a `Condition` evaluates to `False`, to skip the guarded `Task`
only and allow dependent `Tasks` to execute, users can pass in the
`continueAfterSkip` field and set it to `true` or `yes` (case insensitive).
The field defaults to `false` -- the rest of the `Task` branch is skipped
by default as it was previously.

When `continueAfterSkip` is set to `True`, subsequent `Tasks` based on
ordering dependencies should execute and the subsequent `Tasks` based
resource dependencies will have resource validation errors.
@jerop
Copy link
Member

jerop commented Aug 4, 2020

I'm trying to create the following pipeline:

Task(git clone repo) -> Task(run tests) -> Task(create git issue if tests failed) -> Task(Send out slack notification)

The create git issue task is conditional based on the results of the tests that were run previously.

I'd like to be able to run the last slack notification task after either the create git issue task completed or if it was not run due to condition (the slack message is dynamically created based on execution flow).

@prantaa when the second Task (run tests) fails, the whole pipeline will fail so the subsequent Tasks won't be executed.

Separately, you can explore using finally in pipelines to send out notifications. Final Tasks are guaranteed to be executed after other Tasks have completed regardless of the outcome (success/failure), which may be useful for notifications.

@prantaa
Copy link
Author

prantaa commented Aug 17, 2020

@jerop The second task doesn't necessarily need to fail. The second task runs the tests which if the tests fail then that could be indicated in a task result variable without failing the task and further passed onto later tasks which work conditionally based on the previous task result.

I don't think finally tasks support referencing task results from other tasks which is what we would need.

@jerop
Copy link
Member

jerop commented Aug 31, 2020

@jerop The second task doesn't necessarily need to fail. The second task runs the tests which if the tests fail then that could be indicated in a task result variable without failing the task and further passed onto later tasks which work conditionally based on the previous task result.

I don't think finally tasks support referencing task results from other tasks which is what we would need.

@prantaa in that case, using WhenExpressions (that support referencing task results) and whenSkipped which are coming out soon should solve your use case -- will update you when they're available

@pritidesai
Copy link
Member

Supporting task results in a finally taskis in progress, its been delayed by few weeks now, hoping to have changes in soon.

@tekton-robot
Copy link
Collaborator

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 tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 1, 2021
@pritidesai
Copy link
Member

@prantaa pipeline 0.21.0 is releasing soon with the finally tasks support referencing task results from other tasks. The feature is already available on master. Please confirm it satisfies your use case 🙏

@tekton-robot
Copy link
Collaborator

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 tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 3, 2021
@tekton-robot
Copy link
Collaborator

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link
Collaborator

@tekton-robot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants