-
Notifications
You must be signed in to change notification settings - Fork 222
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
Adding TEP for accessing task execution status at runtime #234
Conversation
/kind tep |
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 really like your approach to narrow the scope of this feature down to just the execution status! I'd been assuming we'd want to provide the entire status but the more I think about it, it probably makes more sense to be intentional about the individual fields we want to provide (and understand why they are needed)
My main feedback:
- I'd like to map these values more directly to the possible values that the succeeded condition can take on and potentially handle states that aren't represented there with additional variable replacement values (but maybe leaving them out for now; i.e. start with the bare minimum now and build on it)
- In the spirit of supporting additional values, structuring this such that we can add more values (e.g.
context.pipelineRun.Tasks.deployment.status
instead of justcontext.pipelineRun.Tasks.deployment
) - I also wonder if it would make sense to constrain this just to finally tasks for now, since we don't have any use cases for other tasks and also since this can lead to some racy behavior
af85b2a
to
108662a
Compare
108662a
to
12277cb
Compare
|
||
## Proposal | ||
|
||
Introduce a new context variable `$(context.pipelineRun.Tasks.<pipelineTask>.status)` which resolves to one of the execution states: |
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.
Small thing related to variable naming - we already have a tasks
variable with the following form:
$(tasks.<task-name>.results.<result-name>)
I am wondering if it makes sense to continue following this form for status variables as well? Was there a particular reason that this var was nested under context.pipelineRun
?
Alternatively, should we consider moving the results
variables under context.pipelineRun
?
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 am wondering if it makes sense to continue following this form for status variables as well?
Following results
form, would lead us to $(tasks.<task-name>.status)
🤔
Was there a particular reason that this var was nested under context.pipelineRun?
Status is something not generated by the task itself, its something controller generating for each task which I think falls under context.pipelineRun
similar to pipelineRun name, id, etc. And in future, I am anticipating, this is something auto generated without having task specify explicit mapping i.e. script can directly access context variable with $(context.pipelineRun.[*])
.
I am happy to change it though.
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.
Status is something not generated by the task itself, its something controller generating for each task which I think falls under context.pipelineRun similar to pipelineRun name, id, etc.
This makes sense, I hadn't thought of it this way, thanks @pritidesai !
12277cb
to
1d8d120
Compare
I have renamed the file, TEP number 27 was picked by other TEP and merged 😢 Will up the number when its close to getting merge. |
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.
This is looking great!
I have one remaining quibble, carrying on @sbwsg 's thoughts about the structure of the variable used for substitution but am happy to approve and merge before we sort that out if needed!
| ----- | ----------- | | ||
| `Succeeded` | The `pipelineTask` was successful i.e. a respective pod was created and completed successfully. The `pipelineTask` had a `taskRun` with `Succeeded` `ConditionType` and `True` `ConditionStatus`. | | ||
| `Failed` | The `pipelineTask` failed i.e. a respective pod was created but exited with error. The `pipelineTask` has a `taskRun` with `Succeeded` `ConditionType`, `False` `ConditionStatus` and have exhausted all the retries. | | ||
| `None` | no execution state available either (1) the `pipeline` stopped executing `dag` tasks before it could get to this task i.e. this task was not started/executed or (2) the `pipelineTask` is `skipped` because of `when expression` or one of the parent tasks was `skipped`. It is part of `pipelineRun.Status.SkippedTasks`. | |
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 think starting with this set makes a lot of sense and we can always add more states later!
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.
yup 👍
I'm happy to merge this! As far as I'm concerned: /approve Maybe @sbwsg @afrittoli @vdemeester or others want to weigh in? |
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.
Approve from my side too but I think you need someone from another org to given the final +1!
- name: rollback | ||
params: | ||
- name: deployment-state | ||
value: "$(context.pipelineRun.Tasks.deployment.status)" |
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.
One more nit about the variable - if we stick with this format, I am wondering why we use Tasks
instead of tasks
? Apologies if I missed this elsewhere in the conversation!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bobcatfish, sbwsg 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 |
total nit @pritidesai I think the filename should change from teps/XXXX-task-execution-status-at-runtime.md to teps/0027-task-execution-status-at-runtime.md |
also looks like https://github.com/tektoncd/community/pull/244/files is also TEP-0027 so maybe we change this one XD |
1d8d120
to
b5f8d12
Compare
picked up |
b5f8d12
to
e320b5b
Compare
@afrittoli its ready for review, PTAL 🙏 |
This TEP has a proposal on how to access task execution status at runtime within the pipeline.
e320b5b
to
372cfa5
Compare
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.
Thanks for this!
It looks good and I look forward to this feature.
I think it will combine nicely with when
expressions on finally tasks, allowing pipeline editors to skip unneeded finally tasks without altering the definition of the task itself (great for re-use).
/lgtm
## Alternatives | ||
|
||
* If the states defined in this [Proposal](#proposal) are not clear, one alternative is to change these states and align them | ||
to `pipelineRun` [execution status](https://github.com/tektoncd/pipeline/blob/master/docs/pipelineruns.md#monitoring-execution-status) (`Unknown`, `True`, `False`). Also change the proposed variable pattern to match these states. |
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 kind of liked this alternative, since it maps nicely to the condition, and we could later extend this to give access to other conditions or other fields in the condition, e.g. by doing:
tasks.<pipelineTask>.conditions.succeeded.status
However this syntax would be much more verbose, and if we need in future more details about conditions we can still introduce the conditions
field.
This TEP has a proposal on how to access task execution status at runtime within the pipeline.
Issue: tektoncd/pipeline#1020
PoC: tektoncd/pipeline#3390