-
Notifications
You must be signed in to change notification settings - Fork 121
[pipeline-to-taskrun] Add custom task that runs a Pipeline as a TaskRun 🍙 #770
Conversation
/assign @jerop |
/assign @afrittoli |
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 the detailed documentation!!
please add pipeline-to-taskrun
here to trigger its tests:
experimental/test/presubmit-tests.sh
Line 61 in 6ae0915
projects="catalogs cel commit-status-tracker generators helm hub oci pipeline/cleanup pipelines-in-pipelines tekdoc task-loops notifiers/github-app cloudevents" |
can't see its tests in the logs
98279da
to
8acaeca
Compare
Thanks for catching that @jerop!! |
/me slowly watches all the tests fail |
8acaeca
to
cf3ba06
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.
looks great! so excited to see this feature 😀
pipeline-to-taskrun/README.md
Outdated
This is a controller that enables an experimental [custom task](https://github.com/tektoncd/pipeline/blob/main/docs/runs.md) | ||
that will allow you to execute a Pipeline (with [limited features](#supported-pipeline-features)) via a TaskRun, enabling you to | ||
run a Pipeline in a pod ([TEP-0044](https://github.com/tektoncd/community/blob/main/teps/0044-decouple-task-composition-from-scheduling.md)). |
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.
it would be useful to add some details here on why a user may want to do this, maybe some use cases and benefits (with a link to the TEP for further information)
pipeline-to-taskrun/README.md
Outdated
Currently supported features: | ||
|
||
* Sequential tasks (specified using [`runAfter`](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#using-the-runafter-parameter)) | ||
* [Params](https://github.com/tektoncd/pipeline/blob/main/docs/pipelines.md#specifying-parameters) |
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.
it'd be helpful to specify that string params only are supported, in case a user doesn't get to the part below that says array params are not yet supported
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: pip |
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.
app.kubernetes.io/part-of: pip | |
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun |
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: pip |
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.
app.kubernetes.io/part-of: pip | |
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun |
tr, err = getMergedTaskRun(run, pSpec, taskSpecs) | ||
if err != nil { | ||
run.Status.MarkRunFailed(ReasonRunFailedValidation, | ||
"Could not create TaskRun for the pipeline - %v", err) | ||
return fmt.Errorf("couldn't create taskrun for pipeline %s: %v", run.Spec.Ref.Name, err) | ||
} | ||
|
||
logger.Infof("Creating a new TaskRun object %s", tr.Name) | ||
if _, err := r.pipelineClientSet.TektonV1beta1().TaskRuns(run.Namespace).Create(ctx, tr, metav1.CreateOptions{}); err != nil { | ||
logger.Errorf("Run %s/%s got an error creating TaskRun - %v", run.Namespace, run.Name, err) | ||
run.Status.MarkRunFailed(ReasonRunFailedCreatingPipelineRun, | ||
"Run got an error creating pipelineRun - %v", err) | ||
return err | ||
} |
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.
following this section is a bit confusing i.e. it's not clear when taskrun is created
e.g. we have an error "couldn't create taskrun for pipeline", then later we're "creating a new taskrun object"
may help if the first part used merge
and second part part used create
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.
or you could add comments like in the other sections above, they were really helpful - thanks!
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.
both great suggestions! ive made a couple updates but lemme know if it's not enough of a change and i could still make it more clear
34eeddd
to
b50f6bc
Compare
Should be ready for another look @jerop ! 🙏 |
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.
very exciting! thank you @bobcatfish 😁
/lgtm
@afrittoli looks like I'm not allowed to approve because the owners file is not yet in, the top level owners have to approve cc @tektoncd/experimental-maintainers |
I had tried to add the custom task and OWNERS file all at once in tektoncd#770 but @jerop pointed out it's probably a better approach to just add the OWNERS file first, which would allow getting the initial approval needed to kick off the project and from then on the project OWNERS can take care of reviews (and she documented this in tektoncd#782 !) So this commit adds just the OWNERS (more welcome if anyone else is interested!) for the pipeline to taskrun custom task, and there will be a follow-up PR with the initial controller logic. Project proposal: tektoncd/community#447
…ustom task 🎁 I had tried to add the custom task and OWNERS file all at once in tektoncd#770 but @jerop pointed out it's probably a better approach to just add the OWNERS file first, which would allow getting the initial approval needed to kick off the project and from then on the project OWNERS can take care of reviews (and she documented this in tektoncd#782 !) So this commit adds just the OWNERS (more welcome if anyone else is interested!) for the pipeline to taskrun custom task, and there will be a follow-up PR with the initial controller logic. Project proposal: tektoncd/community#447
…ustom task 🎁 I had tried to add the custom task and OWNERS file all at once in #770 but @jerop pointed out it's probably a better approach to just add the OWNERS file first, which would allow getting the initial approval needed to kick off the project and from then on the project OWNERS can take care of reviews (and she documented this in #782 !) So this commit adds just the OWNERS (more welcome if anyone else is interested!) for the pipeline to taskrun custom task, and there will be a follow-up PR with the initial controller logic. Project proposal: tektoncd/community#447
b50f6bc
to
8536c44
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 @bobcatfish 😁
/lgtm
/approve |
In tektoncd#770 I tried to add the custom task and OWNERS file - with @jerop's help I realized it would be easier to add the OWNERS file first so that OWNERS can review the custom task itself - but even after that I was still changing a file in the top level test dir to add the custom task to the list of tests kicked off which needs top level OWNERS approval - so this commit is doing that separately. Looking at the script it should be safe to add a directory that doesn't exist because it should just get ignored
In #770 I tried to add the custom task and OWNERS file - with @jerop's help I realized it would be easier to add the OWNERS file first so that OWNERS can review the custom task itself - but even after that I was still changing a file in the top level test dir to add the custom task to the list of tests kicked off which needs top level OWNERS approval - so this commit is doing that separately. Looking at the script it should be safe to add a directory that doesn't exist because it should just get ignored
This commit adds a custom task that allows user to run simple sequential Pipelines as one TaskRun - which means the Pipeline can refer to multiple Tasks but run on only one pod. It only supports a subset of Pipeline functionality (more detail on what and why in the README) but is enough that folks can do a lot of what they would have previously used PipelineResources for, e.g. doing a git clone and then doing something with the data, in the same pod, and emit results such as the exact commit sha used. Next steps will be to expand the functionality supported, get feedback, and if the feedback is good, promote this to a top level Pipeline API feature. Experimental project proposal: tektoncd/community#447
Building the custom task on my mac was working just fine but once we started to build it with CI it failed with `no required module provides package github.com/googleapis/gnostic/OpenAPIv2` Turns out this is a known issue: kubernetes/client-go#741 Kinda at a loss as to why other custom tasks aren't running into this and my understanding of go mod is so shallow that I feel like I'm writing with a crayon to fix this (nothing against crayons, they make cool marks) - but anyway I tried to copy what the pipeline go.mod had done since I think that's where the original version came from anyway https://github.com/tektoncd/pipeline/blob/main/go.mod
8536c44
to
388450e
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jerop 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 |
/lgtm |
Changes
This commit adds a custom task that allows user to run simple sequential
Pipelines as one TaskRun - which means the Pipeline can refer to
multiple Tasks but run on only one pod.
It only supports a subset of Pipeline functionality (more detail on what
and why in the README) but is enough that folks can do a lot of what
they would have previously used PipelineResources for, e.g. doing a git
clone and then doing something with the data, in the same pod, and emit
results such as the exact commit sha used.
Next steps will be to expand the functionality supported, get feedback,
and if the feedback is good, promote this to a top level Pipeline API
feature.
Experimental project proposal: tektoncd/community#447
Added @wlynch @jerop as owners also, just ping me if you've changed your minds XD
p.s. shout out to the yaml test lib @imjasonh - i had to do some truly terrible things to make it work sometimes but it was still SOOOO much better than creating go structs XD
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.