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

Adding TEP for accessing task execution status at runtime #234

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

pritidesai
Copy link
Member

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

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 16, 2020
@pritidesai pritidesai changed the title Adding TEP for accessing task execution status at runtime Adding TEP for accessing task execution status at runtime - 0027 Oct 16, 2020
@pritidesai
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 Oct 16, 2020
Copy link
Contributor

@bobcatfish bobcatfish left a 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 just context.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

teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved

## Proposal

Introduce a new context variable `$(context.pipelineRun.Tasks.<pipelineTask>.status)` which resolves to one of the execution states:
Copy link

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?

Copy link
Member Author

@pritidesai pritidesai Oct 28, 2020

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.

Copy link

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 !

teps/0027-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
@pritidesai
Copy link
Member Author

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.

@pritidesai pritidesai changed the title Adding TEP for accessing task execution status at runtime - 0027 Adding TEP for accessing task execution status at runtime Oct 28, 2020
Copy link
Contributor

@bobcatfish bobcatfish left a 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!

teps/XXXX-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/XXXX-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
teps/XXXX-task-execution-status-at-runtime.md Outdated Show resolved Hide resolved
| ----- | ----------- |
| `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`. |
Copy link
Contributor

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!

Copy link
Member Author

Choose a reason for hiding this comment

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

yup 👍

@bobcatfish
Copy link
Contributor

I'm happy to merge this!

As far as I'm concerned:

/approve

Maybe @sbwsg @afrittoli @vdemeester or others want to weigh in?

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2020
Copy link

@ghost ghost left a 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)"
Copy link

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!

@tekton-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bobcatfish
Copy link
Contributor

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

@bobcatfish
Copy link
Contributor

also looks like https://github.com/tektoncd/community/pull/244/files is also TEP-0027 so maybe we change this one XD

@pritidesai
Copy link
Member Author

picked up 0028 for this TEP for now, will move 0028 to next available number.

@pritidesai
Copy link
Member Author

@afrittoli its ready for review, PTAL 🙏

This TEP has a proposal on how to access task execution status
at runtime within the pipeline.
Copy link
Member

@afrittoli afrittoli 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 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.
Copy link
Member

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.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 3, 2020
@tekton-robot tekton-robot merged commit b16dc94 into tektoncd:master Nov 3, 2020
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/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.

5 participants