-
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
WhenExpressions: support ANY match behavior #3591
Comments
@bitsofinfo if possible, could you please share more specifics of this use case? it'd help to have an example of what the N tasks are doing and what the something else to run is |
pipeline kicks off 3 parallel deployments, if any one of them fails, they all have to get rolled back |
thank you @bitsofinfo! assuming that success/failure is indicated by a result, instead of task failure (that'd cause the pipeline to fail), can this use case be solved by checking that the failure status is in an array of the results from the tasks? tasks:
- name: deploy-1
taskSpec:
results:
- name: status
...
- name: deploy-2
taskSpec:
results:
- name: status
...
- name: deploy-3
taskSpec:
results:
- name: status
...
- name: rollback
when:
- input: failure
operator: in
values:
- "$(tasks.deploy-1.results.status)"
- "$(tasks.deploy-2.results.status)"
- "$(tasks.deploy-3.results.status)"
taskSpec:
... |
thanks Each of my so... i think this might work, w/ the current ALL behavior
will go try this. still, any behavior would be a nice option. |
nice! glad you have a solution for the use case 😃
the |
thx! |
actually... @jerop realizing that unfortunately this still wont work example: deploy-1 succeeds, last-exit-code = 0 Will not pass as 0 is in the list
... and I can't do the inverse because the "input" is not necessarily known, the exit code could be anything !=0
|
is using last exit code as a result a workaround to avoid your pipeline failing or is it something you actually want? if it's a workaround, maybe the setup we need for this use case is that:
in the meantime, i'd recommend changing your result to represent the success/failure instead of using the exit code directly (if exit code == 0, then result is success, otherwise result is failure) -- this would allow you to use the setup in #3591 (comment) |
I write in any case, all I'm asking for is an "ANY" option for WhenExpressions. Would be simple to add. I'm just an advocate for making it as flexible as possible for the end-user, vs changing their implementation to adhere with limited evaluation capabilities of the framework itself. Similar to the arguments in #3468. Seems adding a config flag for |
we want to add features only when they're absolutely necessary and that's why we need to find use cases that can't be solved or that are challenging to solve, further described in the simplicity section of the design principles adding is |
I think we are talking about |
I guess one use case we cannot satisfied:
3 parallel tasks, if one if them success, the 4th task will start to run. I means the requirements is: if any of the tasks success, do not wait others, the 4th should execute immediately. @jerop |
@vincent-pli thanks for sharing your use case! in that scenario, the 3 parallel tasks are all parent tasks to the 4th task (because it uses their results) so the 4th task won't be added to the execution queue until all its parent tasks are done is it possible to share what the forth task is doing? i'm thinking that it could be best suited for a finally task, especially given that:
|
@bitsofinfo @vincent-pli check out the newly-added common expression language custom task which may be helpful for your use cases |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
adding a reference to a slack thread where a user made a request for "OR" logic support in https://tektoncd.slack.com/archives/CJ62C1555/p1636362405078900 /lifecycle frozen |
I have a pipeline whereby we have logic a little like this, and arrived here looking for exactly the same thing in the hope such support was now available, or in the pipeline:
Basically we have two inputs, those inputs each directly control whether a certain branch in the pipeline is actived, but earlier in the pipeline there are some pre-req steps that are needed only if one or more of those optional branches are traversed. We can't use the status of the app1/app2 install steps as this step happens before they do. The hacky workaround we put in place at the moment is this, which works as we use empty string in the parameter to indicate "don't install that application":
We did want to do more complex logic based on content of the param (which carries a version number), but I don't see how we can do that without the kind of ANY match support discussed in this issue. Example: One app only needs this step depending on the version chosen, the other needs it as long as it's installed (any version)
|
Hi, 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 |
Feature request
The default behavior of:
If ALL the WhenExpressions evaluate to True
Needs a simple option to toggle the behavior to be:
If ANY of the WhenExpressions evaluate to True
Use case
I have a scenario where I have N spawned tasks, and if any ONE of their results have a particular value, I need something else to run.
The text was updated successfully, but these errors were encountered: