-
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
APIs for conditionals #1031
APIs for conditionals #1031
Conversation
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.
Most of my review comments here are stylistic / nits. Overall approach lgtm! Will review again when it's moved out of WIP.
pkg/reconciler/v1alpha1/pipelinerun/resources/conditionresolution.go
Outdated
Show resolved
Hide resolved
|
/test pull-tekton-pipeline-integration-tests |
/test pull-tekton-pipeline-integration-tests |
1 similar comment
/test pull-tekton-pipeline-integration-tests |
e5c545c
to
97bea8e
Compare
/retest |
/lgtm |
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.
Looking good, few remarks.
The second commit adds an initial implementation.
In this implementation, condition evaluations aka ConditionChecks are
backed by TaskRuns. All conditionChecks associated with aPipelineTask
have to succeed before the task is executed. If a ConditionCheck fails,
the PipelineTask's associated TaskRun is marked failed i.e. its
Status.ConditionSucceeded
is False. However, the PipelineRun itself
is not marked as failed.
So, we are using TaskRun
for running the condition, which is nice I think — because we can re-use our tooling. Looking quickly at the implementation, the TaskRun
created will be attached to the PipelineRun
(aka created the same way as normal PipelineTask
-> TaskRun
). I wonder how current tools (dashboard
, the cli
, …) will handle that, or how should they handle that – like how tkn taskrun list
will show TaskRun
vs Condition
(I am thinking outloud).
I need a bit more time to dig into it (and test) but initial review, looks good !
pkg/reconciler/v1alpha1/pipelinerun/resources/pipelinerunresolution.go
Outdated
Show resolved
Hide resolved
Does the CLI/dashboard use the labels (i.e. If they are using the labels, then the conditionCheck taskruns also add the same labels as a regular taskrun. However, in addition, they also have the |
c8311f7
to
6e0b29e
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.
Nice work, thank you for this! This feature is really handy and its implementation using CRD + TaskRuns is consistent with the rest of Tekton.
One question I have is how you envision the lifecycle of this new CRD.
Conditions used in pipelines but they are independent, so they must be provisioned separately, and they stay in the system after the PipelineRun
is deleted. Are we going to create and delete condition all the time, or are they meant to be provisioned once and stay around and be used by all pipelineruns that needs them?
It might make sense to have a few common conditions added to the catalog project.
I left a few minor comments. They only bit where I'd like to see a change before this is one YAML test case defined in the example folders, so we can run one e2e test with that.
} | ||
} | ||
|
||
func TestUpdateTaskRunState_WithFailingConditionChecks(t *testing.T) { |
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: It looks as if it may be possible to factor up TestUpdateTaskRunState_WithPassingConditionChecks and TestUpdateTaskRunState_WithFailingConditionChecks into a single func that runs the test twice with different inputs.
c26521f
to
7a83610
Compare
I am very excited about this! My initial reaction is pretty similar to the discussion @afrittoli and I are having in #837 - maybe we could add this over a couple PRs? e.g. we could start with a PR that adds the types and the validation maybe? Would allow us to focus on reviewing the interface before reviewing the implementation. Just let me know if that would be too disruptive to what you are doing @dibyom , this is feedback I should have given a couple weeks ago instead of suddenly now :( If needed I can review as a whole!
I am wondering about this - esp. since I happen to know that TaskRuns have some specific behaviour in them when they are owned by a PipelineRun 😅 which you probably dont want (see #1068 😅 ) (not that this should be the case! dont let that alone stop you from using TaskRuns). I would almost rather see the useful part of TaskRuns factored out to be more easily called by something else vs. actually creating a TaskRun 🤔 (I also wonder if we're going to end up wanting to reuse that logic more as we go, e.g. via. Notfications #49, and in event triggering we're probably gonna want to create Conditions too ...) Feel free to disagree with me here tho, I've only glanced at the implementation and you're way more familiar with it 🙇♀ |
Not at all, this PR is already broken into commits that first adds the types and then the implementation. Gonna drop the later commits and put them in a separate PR. As far as using Also, @afrittoli thanks a lot for the review. Will add the YAML tests. You are right that conditions are created once and then reused in pipelines (much like tasks are used in pipelines). The plan is to add basic conditions to Tekton (the catalog is a nice idea, did not consider that!) |
Dropped the other commits and this PR is now just the initial API. PTAL @bobcatfish ! |
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 you for all the updates and for splitting the PR in multiple parts!
/cc |
@m1093782566: GitHub didn't allow me to request PR reviews from the following users: m1093782566. Note that only tektoncd members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
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 wonder if there is a way that we can still reuse a lot of the TaskRun logic, but also narrow the amount of functionality we are exposing for conditionals? One idea: still use TaskRuns underneath (i.e. create a TaskRun in order to fulfill a Condition) but make a new ConditionStatus that only contains fields that make sense for Conditions, i.e. we can treat the fact that TaskRuns are being used under the surface as an implementation detail and not expose it to the user at all - that way we can approach refactoring it later without changing the user experience.
type ConditionCheck TaskRun | ||
|
||
// ConditionCheckStatus is the observed state of a ConditionCheck | ||
type ConditionCheckStatus TaskRunStatus |
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 you said you're already digging a bit into refactoring this so that we don't reuse Task runs but here's some more food for thought! Looking at what we've got in TaskRunStatus
we've got these fields:
Results *Results "json:\"results,omitempty\"" # Oh boy what even is this? Should probably delete this... 😅
# These seems like they make sense for a Condition
Status "json:\",inline\""
PodName string "json:\"podName\""
StartTime *Time "json:\"startTime,omitempty\""
CompletionTime *Time "json:\"completionTime,omitempty\""
# Since we only have one step ever it's kinda odd that we have a "steps" field with multiple steps in it
Steps []StepState "json:\"steps,omitempty\""
# I'm doubtful these make sense for a condition
RetriesStatus []TaskRunStatus "json:\"retriesStatus,omitempty\""
ResourcesResult []PipelineResourceResult "json:\"resourcesResult,omitempty\""
# Would it make sense to have something explicit like "condition result" to say "pass" or "fail" or similar?
# (Just ignore if it's not worth it)
My inclination here would be to add as little functionality as we can possibly get away with - it's always easier to add more later than to remove it!
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.
Totally agree. I think reusing the TaskRunStatus
ties us to the TaskRun implementation which is not something we want!. Will have this updated soon!
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.
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.
Also, from the comment for Results, it seems like it points to location logs have been uploaded to though it seems like its not fully implemented (cc @sbwsg )
No worries leaving that as-is - almost definitely leftover from our first attempt at the API 😅
This commit adds the basic APIs for conditionals in Tekton: 1. Condition CRD defines a condition how a condition is evaluated i.e. the container spec and any input parameters. 2. The `Conditions` field in `PipelineTask` references `Condition` resources that have to pass before the task is executed. 3. The `ConditionChecks` field in `PipelineRun.Status.TaskRuns` surfaces the status of conditions that were evaluated for that particular task.
The following is the coverage report on pkg/.
|
Nice! Thanks for making the status change so quickly @dibyom looking good to me! /lgtm |
In response to this:
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. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: afrittoli, bobcatfish, dibyom 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 |
Changes
The commit adds the basic APIs for conditionals in Tekton:
the container spec and any input parameters.
Conditions
field inPipelineTask
referencesCondition
resources that have to pass before the task is executed.
ConditionChecks
field inPipelineRun.Status.TaskRuns
surfacesthe status of conditions that were evaluated for that particular task.
Part of #1019
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide
for more details.
Release Notes