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

allow more complex when conditions, minimally regex #3468

Open
Tracked by #7415
itewk opened this issue Oct 28, 2020 · 37 comments
Open
Tracked by #7415

allow more complex when conditions, minimally regex #3468

itewk opened this issue Oct 28, 2020 · 37 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@itewk
Copy link

itewk commented Oct 28, 2020

Feature request

currently the when statement that replaced the Condition CRD only has the ability to check if a given string is in a list of other strings. This is limiting.

Need the ability to at the least do pattern matching, ex, regex.

Use case

Transitioning from a Jenkins pipeline to a Tekton pipeline. In Jenkins have when condition on steps to check the branch and compare it against patterns to decide whether to exuecute the step. IE, for "PROD deploy" step verify that on the main or release/.* branch and for "Merge Request Deploy" check feature/.*. When translating to Tekton there is no way to do this blocking our ability to translate the logic.

Other

This is the problem bit, that it has a hard coded == https://github.com/tektoncd/pipeline/blob/master/pkg/apis/pipeline/v1beta1/when_types.go#L82. Need the ability to control that operation, or just change that op to a regex match which then will work for == as well.

Ideally this wouldn't be hard coded and rather any arbitrary function that returns true/false could be supplied to make the deicion to future proof against any possible future ways someone may want to add a condition to a step.

@itewk itewk added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 28, 2020
@jerop
Copy link
Member

jerop commented Oct 29, 2020

For now, you could possibly solve your use case by creating a Task that compares a branch Param against a pattern Param and produces a Result indicating whether it matches....then use that Result in WhenExpressions to guard the subsequent Tasks

Separately, one alternative for supporting regex matching in WhenExpressions is by adding another Operator (maybe Matches) instead of modifying the In and NotIn Operators

@itewk
Copy link
Author

itewk commented Oct 29, 2020

@jerop thanks for the work around idea. I will give it a try and report back. and I like the new operator idea.

@bitsofinfo
Copy link

bitsofinfo commented Nov 25, 2020

Definitely need more flexibility w/ WhenExpressions:

All standard operators should be supported (in, not in, >, <, >=, <= and ==/!= aliased to in/notin just to be friendly

Ideally just supporting an "expression" literally via CEL (+regex like the op requested) would be great to. Really can just open it up to more possibilities you can't predict. Keep it as open as possible. #2812

Here is my scenario:

I have a task who's result is a metric. Then whether or not a subsequent task proceeds is based if that metric meets a threshold. (think, <=, >=, <, > etc)

I guess I could change the task's "result" to be an "interpretation" of that metric that is compatible with what WhenExpression currently supports (or create an intermediary Task that interprets the result, then the interpreters result becomes the input to the WhenExpression) but this all seems like hoops to jump through.

I think of tasks like functions. the caller (pipeline) makes the interpretation of the result from the call to the function, not the function itself. The caller in this case is the pipeline and the function is the task who's "output/result" is a metric. I want to be able to re-use my task that "does X and returns metric" and not tightly couple it to the context its used in by doing the interpretation of the result itself. In diff contexts (pipelines) where/when the task is invoked, the metric result can be interpreted in diff ways.

Do be able to do this requires a more flexible "interpreter" mechanism if WhenExpression is the only means currently to do it now (outside of deprecated conditions) or intermediary "result generator/interpretor tasks". Its just too limited with in/notin imho

leverage the power of all the various expression dsls out there to open it up to a "context object" that contains all the pipeline params, task results and just let the operator (user) craft an expression of what they need to evaluate.

@bitsofinfo
Copy link

bitsofinfo commented Dec 3, 2020

Also the default behavior of:

If all the WhenExpressions evaluate to True

Needs any option to toggle the behavior to be:

If ANY of the WhenExpressions evaluate to True

I have this scenario where I have multiple spawned tasks, and if any ONE of them fails, I need something else to run.

@bitsofinfo
Copy link

#3591

@jerop
Copy link
Member

jerop commented Jan 21, 2021

@itewk @bitsofinfo check out the newly-added common expression language custom task which may be helpful for your use cases

@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 Apr 21, 2021
@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 May 21, 2021
@bitsofinfo
Copy link

/remove-lifecycle rotten

@tekton-robot tekton-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label May 25, 2021
@Evertras
Copy link

Is this being actively worked on somewhere? Or is this something I could help out with? We would love to have this natively in Tekton for our users to write their own when expressions with basic regex matching rather than deal with a custom task.

@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 Nov 15, 2021
@bitsofinfo
Copy link

/remove-lifecycle stale

@tekton-robot tekton-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 17, 2021
@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 15, 2022
@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 17, 2022
@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.

@jacobbrozenick
Copy link

/reopen

Its hard to believe this is not a feature, WhenExpressions are so limited limited without it, honestly its hard be believe this wasn't part of the initial deployment.

@tekton-robot
Copy link
Collaborator

@jacobbrozenick: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Its hard to believe this is not a feature, WhenExpressions are so limited limited without it, honestly its hard be believe this wasn't part of the initial deployment.

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.

@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 Dec 14, 2022
@bitsofinfo
Copy link

/remove-lifecycle stale

@tekton-robot tekton-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 16, 2022
@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 Mar 16, 2023
@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 Apr 15, 2023
@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.

@jerop
Copy link
Member

jerop commented Jul 20, 2023

/lifecycle frozen
/reopen

@tekton-robot tekton-robot reopened this Jul 20, 2023
@tekton-robot
Copy link
Collaborator

@jerop: Reopened this issue.

In response to this:

/lifecycle frozen
/reopen

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.

@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Jul 20, 2023
@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.

@github-project-automation github-project-automation bot moved this from In Progress to Done in Tekton Community Roadmap Aug 19, 2023
@jerop
Copy link
Member

jerop commented Oct 4, 2023

/lifecycle frozen

@jerop jerop reopened this Oct 4, 2023
@tekton-robot tekton-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Oct 4, 2023
@github-project-automation github-project-automation bot moved this from Done to In Progress in Tekton Community Roadmap Oct 4, 2023
@Yongxuanzhang
Copy link
Member

Hi all, the CEL in WhenExpression has been supported in release v0.53 , which can be used to address the use case. Please try out the feature and if you have any suggestions, feel free to comment on this issue: #7358

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/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
Status: In Progress
Development

No branches or pull requests

7 participants