-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conditions Beta: Skipping #2995
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The following is the coverage report on the affected files.
|
/kind feature |
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
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.
The following is the coverage report on the affected files.
|
@jerop: The following tests failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/hold I think we'll want to get tektoncd/community#159 merged as implementable before we can merge this |
agreed, was implementing the proof of concepts to verify the ideas, will wait for approvals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly just commented on the examples - also I think we'll want to add as well:
- I think there's a pipeline_defualts or similar file that we can use to set the default value of the field
- imo we should treat only the string "true" or "false" as valid - OR even better, can we use an actual bool? if we are using strings, we should probably add some validation at least
- probably at least one e2e test, esp. if we want to cover an error case
(speaking of validation: i still think instead of having the "resolution error (failed)" case, we can validate this at pipeline creation time and treat it as invalid - i know its not consistent with finally + results, but i think it's a better experience for the user to get more info sooner)
- name: file-missing | ||
taskRef: | ||
name: file-missing | ||
continueAfterSkip: `true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i think this should be quotation marks
name: conditional-pipeline | ||
spec: | ||
tasks: | ||
- name: task-should-be-skipped # failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
im not sure what "failed" means here - maybe "skipped"?
steps: | ||
- name: echo-file-exists | ||
image: ubuntu | ||
script: 'echo UNEXPECTED!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could make this task exit with a non-zero exit code, so that if it wasn't skipped the pipeline would fail? not important but just wondering :D
taskRef: | ||
name: echo-expected | ||
runAfter: | ||
- task-should-be-skipped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my understanding is that this pipeline run will succeed even if continueAfterSkip doesn't work properly - maybe we can add a finally task that verifies that task-should-execute executed? e.g. (until we have #2557!) we could write to a workspace in this task, and the finally task could verify that the workspace was written to?
value: "$(params.a)" | ||
- name: b | ||
value: "$(params.b)" | ||
- name: sum-and-multiply # should execute, resolution error (failed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually we don't have examples that fail, cuz we want the examples to show successful runs that folks can copy
Changes
When a
Condition
fails, the guardedTask
and its branch(dependent
Tasks
) are skipped. ATask
is dependent on and in thebranch of another
Task
as specified by ordering usingrunAfter
or byresources using
Results
,Workspaces
andResources
.In some use cases of
Conditions
, when aCondition
evaluates toFalse
, users need to skip the guardedTask
only and allow dependentTasks
to execute. An example use case is when there’s a particularTask
that aPipeline
wants to execute when the git branch isdev/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 inthis issue.
In this PR, we add a
continueAfterSkip
field to specify whether toterminate the whole
Task
branch, or to skip the guardedTask
onlyand continue with the rest of the
Task
branch.When a
Condition
evaluates toFalse
, to skip the guardedTask
only and allow dependent
Tasks
to execute, users can pass in thecontinueAfterSkip
field and set it totrue
oryes
(case insensitive).The field defaults to
false
-- the rest of theTask
branch is skippedby default as it was previously.
When
continueAfterSkip
is set toTrue
, subsequentTasks
based onordering dependencies should execute and the subsequent
Tasks
basedresource dependencies will have resource validation errors.
TEP: tektoncd/community#159
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes