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

Add validation for PR infinite timeouts #4539

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

lbernick
Copy link
Member

@lbernick lbernick commented Feb 1, 2022

Changes

Prior to this commit, it was possible to create a PipelineRun with timeouts.tasks or timeouts.finally
set to 0 (no timeout) without setting the timeouts.pipeline to 0. If timeouts.pipeline is not set,
it defaults to the global timeout value, which is not 0. This would imply that timeouts.tasks or timeouts.finally
is longer than timeouts.pipeline, and it's not clear how Tekton should handle this.

This commit results in an error returned to the user if they define a PipelineRun spec as described above,
and documents this behavior.

/kind bug

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in or deleted (only if no user facing changes)

Release Notes

[Bug Fix] Add validation for 0 timeout for `pipelinerun.timeouts.tasks` and `pipelinerun.timeouts.finally`

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Feb 1, 2022
@tekton-robot tekton-robot requested a review from dibyom February 1, 2022 14:55
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 1, 2022
@tekton-robot tekton-robot requested a review from imjasonh February 1, 2022 14:55
@lbernick
Copy link
Member Author

lbernick commented Feb 1, 2022

Related: #4460

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.5% 98.8% 0.3

@bobcatfish
Copy link
Collaborator

nice!! good call, thanks @lbernick

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 2, 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.

thanks for adding this validation @lbernick!

This would imply that timeouts.tasks or timeouts.finally is longer than timeouts.pipeline, and it's not clear how Tekton should handle this.

it seems that the current behavior is that timeouts.pipeline will apply, right? it may be useful for future reference to document this existing behavior in the commit/pr

agree that users setting no/infinite timeouts for tasks while the pipeline has a timeout should be invalid - and if they want the tasks to run for as long as needed up to the pipeline timeout, they can make it explicit in the spec

and timeouts is in alpha (#4460) so this is a good time to fix this

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish, jerop

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

@lbernick
Copy link
Member Author

lbernick commented Feb 2, 2022

it seems that the current behavior is that timeouts.pipeline will apply, right? it may be useful for future reference to document this existing behavior in the commit/pr

I wasn't sure what the existing behavior is so I tried it out with timeouts.tasks = 0 and timeouts.pipeline = 1m. Turns out the pipeline times out after 1m but the taskrun is still marked as running! I'll add some detail to the commit message.

Prior to this commit, it was possible to create a PipelineRun with `timeouts.tasks` or `timeouts.finally`
set to 0 (no timeout) without setting the `timeouts.pipeline` to 0. If `timeouts.pipeline` is not set,
it defaults to the global timeout value, which is not 0. This would imply that `timeouts.tasks` or `timeouts.finally`
is longer than `timeouts.pipeline`, and it's not clear how Tekton should handle this.
Prior to this commit, Tekton in practice handles this situation by timing out the PipelineRun when `timeouts.pipeline`
is reached, but never timing out the TaskRun, which is clearly inconsistent behavior.

This commit results in an error returned to the user if they define a PipelineRun spec as described above,
and documents this behavior.
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.5% 98.8% 0.3

@ghost
Copy link

ghost commented Feb 2, 2022

/lgtm

@tekton-robot tekton-robot assigned ghost Feb 2, 2022
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2022
@lbernick
Copy link
Member Author

lbernick commented Feb 2, 2022

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot merged commit e2b30a5 into tektoncd:main Feb 2, 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/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants