Skip to content

Commit

Permalink
TEP 0007: Conditions Beta Skipping
Browse files Browse the repository at this point in the history
Previously, we'd proposed to adding `continueAfterSkip` field which
defaults to false and can be set to true to execute ordering-dependent
tasks

We want to update that proposal because:
- using string aliases instead of booleans is preferable because,
as described in the Kubernetes API policy, "Think twice about bool
fields. Many ideas start as boolean but eventually trend towards a
small set of mutually exclusive options. Plan for future expansions by
describing the policy options explicitly as a string type alias"
- that naming was misleading

So, we propose using a `whenSkipped` field which defaults to `skipBranch`
and users can set to `runBranch` to execute its branch that's made up of
ordering-dependent tasks only

Further discussed in tektoncd/pipeline#3176
  • Loading branch information
jerop committed Nov 2, 2020
1 parent f70e525 commit 1822047
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions teps/0007-conditions-beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: tep-0007
authors:
- "@jerop"
creation-date: 2020-07-22
last-updated: 2020-08-05
last-updated: 2020-11-02
status: implementable
---

Expand Down Expand Up @@ -295,20 +295,20 @@ We can explore adding more [Operators](https://github.com/kubernetes/kubernetes/

### Skipping

As it is currently in `Conditions`, when a `Guard` evaluates to `False`, the `Task` and its dependent `Tasks` will be skipped by default while the rest of the `Pipeline` will execute. However, when the `Guard` is specified to operate on a missing resource (such as `Param` or `Result`), the Pipeline will exit with a failure.

To provide more flexibility when a `Guard` evaluates to `False`, we propose adding a field - `continueAfterSkip` - that:
- is used to specify whether execute the `Tasks` that are ordering-dependent on the skipped guarded `Task`
- defaults to `false`/`no` and users can set it to `true`/`yes` (case insensitive) to allow for execution of the rest of the branch
- is only supported in guarded `Tasks`; there will be a validation error if `continueAfterSkip` is specified in unguarded `Tasks`
As it is currently in `Conditions`, when `WhenExpressions` evaluate to `False`, the `Task` and its branch (of dependent `Tasks`) will be skipped by default while the rest of the `Pipeline` will execute.

A `Task` branch is made up of dependent `Tasks`, where there are two types of dependencies:
- _Resource dependency_: based on resources needed from parent `Task`, which includes Workspaces, `Results` and Resources.
- _Ordering dependency_: based on runAfter which provides sequencing of `Tasks` when there may not be resource dependencies.
- _Resource dependency_: based on resources needed from parent `Task`, which includes `Results` and `Resources`.
- _Ordering dependency_: based on `runAfter` which provides sequencing of `Tasks` when there may not be resource dependencies.

Setting `continueAfterSkip` on a guarded `Task` with ordering dependencies is valid and the subsequent `Tasks` should execute. However, setting `continueAfterSkip` on a guarded `Task` with resource dependencies is invalid because those dependent `Tasks` will have resource validation errors and fail the whole `Pipeline`. We will add validation to confirm the dependencies allow for passing in the `continueAfterSkip` field.
To provide more flexibility when `WhenExpressions` evaluate to `False`, we propose adding a field - `whenSkipped` - that:
- is used to specify whether to execute `Tasks` that are ordering-dependent on the skipped guarded `Task`
- defaults to `skipBranch` and users can set it to `runBranch` to allow execution of the rest of the branch
- can be specified in `Tasks` guarded with `WhenExpressions` only; there will be a validation error if `whenSkipped` is specified in `Tasks` without `WhenExpressions`
- can take the values `skipBranch` or `runBranch` only; there will be a validation error if anything else is passed to `whenSkipped`
- can be specified guarded `Tasks` with ordering dependencies only; there will be a validation error if `whenSkipped` is specified in `Tasks` with resource dependencies

Here's how a user can use `continueAfterSkip` to execute ordering-dependent tasks:
Here's how a user can use `whenSkipped` to execute ordering-dependent tasks:

```yaml
api: tekton.dev/v1beta1
Expand Down Expand Up @@ -339,7 +339,7 @@ spec:
- input: '$(tasks.file-exists.results.exists)'
operator: In
values: ['false']
continueAfterSkip: 'true'
whenSkipped: runBranch
taskRef:
name: echo-file-exists
- name: echo-hello # executed
Expand Down Expand Up @@ -565,7 +565,7 @@ The `When Expressions` providing `In` and `NotIn` `Operators` may not cover some
## Test Plan

- Provide unit tests and e2e tests for `When Expressions` with varied `Inputs` and `Values`.
- Provide unit tests and e2e tests for `continueAfterSkips` with varied `Task` branches.
- Provide unit tests and e2e tests for `whenSkipped` with varied `Task` branches.

## Alternatives

Expand Down

0 comments on commit 1822047

Please sign in to comment.