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

TEP-0114: Cancellation is required #881

Merged
merged 1 commit into from
Nov 22, 2022
Merged

TEP-0114: Cancellation is required #881

merged 1 commit into from
Nov 22, 2022

Conversation

XinruZhang
Copy link
Member

We shoud mark Custom Task Cancellation as required in Custom Task Beta, because pipeline-level timeout won't work if it is optional.

@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 15, 2022
@jerop jerop changed the title Tep 0114 required cancellation TEP-0114: Cancellation is required Nov 15, 2022
@XinruZhang
Copy link
Member Author

/hold until #880 is merged

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 15, 2022
@XinruZhang
Copy link
Member Author

/assign @jerop @abayer

@XinruZhang
Copy link
Member Author

/unhold

@tekton-robot tekton-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 15, 2022
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @tektoncd/core-maintainers

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2022
@abayer
Copy link
Contributor

abayer commented Nov 16, 2022

/approve

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abayer, jerop, vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@XinruZhang
Copy link
Member Author

/hold explain the cancellation details.

@tekton-robot tekton-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 16, 2022
@XinruZhang
Copy link
Member Author

/unhold

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 16, 2022
@abayer
Copy link
Contributor

abayer commented Nov 16, 2022

👍

@pritidesai
Copy link
Member

/cc @ScrapCodes

@tekton-robot
Copy link
Contributor

@pritidesai: GitHub didn't allow me to request PR reviews from the following users: ScrapCodes.

Note that only tektoncd members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @ScrapCodes

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.

@@ -208,6 +209,19 @@ Remove guarding of `Custom Tasks` behind `enable-custom-tasks` and `enable-api-f
When [TEP-0096: Pipelines V1 API][tep-0096] is implemented to add V1 API, `Custom Tasks` will be gated behind feature
gate `enable-api-fields` being set to `"beta"` - this is out of scope for this TEP (in scope for TEP-0096).

##### Cancellation

Implementing cancellation is now `required` instead of `optional`. If the Custom Task implementor does not support cancellation via `.spec.status`, `Pipeline` timeouts and `PipelineRun` cancellation will not work properly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does properly allude to here?

@ScrapCodes please share your experience here if you have any

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure that cancellation is required, are we planning to have validations now or in future? if no, is this just a documentation change?

Also, do we support pipeline level Timeout for custom task? I remember it was removed?

What are the downside of keeping as: "It is upto the custom task controller to support it." i.e. optional, e.g. not all custom task may want to support it e.g. CEL. Those custom task who do not wish to support they are responsible for not supporting timeout as well as of today.

Today Tekton controller does not depend on custom task's support of cancel, is it going to change?

Pipeline timeouts and PipelineRun cancellation will not work properly.
Can you elaborate?

Copy link
Member Author

@XinruZhang XinruZhang Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pritidesai

What does properly allude to here?

PiplineRun controller has hard code dependencies on status report of CustomRun controller: See the code, which is used to decide if the CustomRun is failed or not.

@ScrapCodes

To ensure that cancellation is required, are we planning to have validations now or in future? if no, is this just a documentation change?

Yes I think we'll have code validations in the future in the ideal world. I opened an issue for it tektoncd/pipeline#5700

do we support pipeline level Timeout for custom task? I remember it was removed?

There are two kinds of timeout for Custom Task:

What we removed is the first one. i.e. we stopped PipelineRun controller to modify CustomRun.status.Conditions upon CustomRun timeout -- (CustomRun executes more than CustomRunSpec.Timeout, see tektoncd/pipeline#5658).

@pritidesai
Copy link
Member

From @ScrapCodes: What are the downside of keeping as: "It is upto the custom task controller to support it." i.e. optional, e.g. not all custom task may want to support it e.g. CEL. Those custom task who do not wish to support they are responsible for not supporting timeout as well as of today.

Hey @XinruZhang, my understanding here is its upto the custom task author whether to implement it or not since it depends on their use case e.g. CEL kind of custom controller v/s wait custom task v/s pipelines in pipelines custom controller.

Please confirm and I can merge this change, thanks! 🙏

@XinruZhang
Copy link
Member Author

XinruZhang commented Nov 22, 2022

Thanks for double check @pritidesai, I strongly support marking Cancellation as required, mainly because:

We'd like the PipelineRun API semantics to be independent of how its sub-resources are implemented. No matter how the custom task is implemented, the PipelineRun behavior should keep consistent. That's said, in Custom Task, anything that Pipeline Controller relies on MUST be strictly defined.

Let's take the following YAML as an example:

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: pr-custom-task-
spec:
  timeouts:
    tasks: "2s"
  pipelineSpec:
    tasks:
    - name: wait
      taskRef:
        apiVersion: wait.testing.tekton.dev/v1alpha1
        kind: Wait-No-Cancellation
      params:
      - name: duration
        value: "60s"

To test it, install a POC Wait Task following https://github.com/XinruZhang/xinru-custom-task/tree/no-cancellation and submit the YAML above

We set PipelineRun.Spec.Timeouts.Tasks as 2s, meaning we expect each tasks to be done in 2s, however, If the wait task didn't implement Cancellation, the Wait task will run until the duration elapses, and the PipelineRun will also need to run for at least "60s"

@XinruZhang
Copy link
Member Author

/kind tep

@tekton-robot tekton-robot added the kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). label Nov 22, 2022
@pritidesai
Copy link
Member

Thank you @XinruZhang, I understand the wait task example you have mentioned above. There is no intend to request any inconsistency in pipelineRun controller.

If I have implemented waiting in my pipeline for 60 seconds, as a user why would I set the timeout of the entire pipeline to 2 seconds? Irrespective of the values chosen here, the cancellation must be required for the use cases which mandate timeout of a pipeline to make that timeout effective so that this example pipeline can be cancelled in 2 seconds. At the same time, this requirement of mandatory cancellation might not even apply to other custom controllers. required can not be made generic for all custom tasks.

I suggest changing:

Implementing cancellation is `required`. If the Custom Task implementor does not support cancellation via `.spec.status`, `Pipeline` timeouts and `PipelineRun` cancellation will not work properly.

to

The custom task is responsible for implementing `cancellation` to support pipelineRun level `timeouts` and `cancellation`. If the Custom Task implementor does not support cancellation via `.spec.status`, `Pipeline` **can not** timeout within the specified interval/duration and **can not** be cancelled as expected upon request.

Let me know what you think. Please feel free to merge it otherwise. Thanks!

@XinruZhang
Copy link
Member Author

Thanks @pritidesai!

I do understand the required cancellation does not apply to some custom tasks.

And I also think we are aligned on that all long running custom tasks MUST implement the cancellation to support PipelineRunSpec.timetouts.

My only concern is, in the future, how do we enforce Custom Tasks conform to Conformance Policy and corresponding Test Suite. See tektoncd/pipeline#5700.

Nevertheless, this is a complex area that requires more discussion, I will update the doc as you suggested -- not required, and get it in. Let's iterate on it :)

cc @lbernick

@pritidesai
Copy link
Member

thank you @XinruZhang 👍

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2022
@tekton-robot tekton-robot merged commit 5d29d75 into tektoncd:main Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: UnAssigned
Development

Successfully merging this pull request may close these issues.

7 participants