Comments (8)
Are you also thinking of adding PipelineRun label to TaskRun in this task?
from pipeline.
@vdemeester: GitHub didn't allow me to assign the following users: tanner-bruce.
Note that only knative members and repo collaborators can be assigned.
For more information please see the contributor guide
In response to this:
/assign @tanner-bruce
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.
from pipeline.
One thing I'm wondering from this description is what the purpose of the labels are? e.g. what use cases do you need labels in (part of this is probably me not being too familiar with labels!)
from pipeline.
One example is the taskRun
pod can include the pipeline name and task name in the logs to make it easier to filter these logs
from pipeline.
It would make sense to add the PipelineRun
name as a label on the TaskRun
from pipeline.
Okay I looked into our options a bit about how to reference child resources (e.g. a PipelineRun
's TaskRuns
, a TaskRun
owns a Build
) (slightly expanding the scope of this task 😅 ), looking at 4 options:
- Labels (e.g.
knative.dev/pipelinerun: kritis-pipeline-run-12321312984
) - Using OwnerReferences
- Using
ObjectReferences
- Using the names of the child resources
Labels
Inside a controller we can use the informer's Lister()
to list by label:
// Try getting the related TaskRuns by label, using the name of this PipelineRun
selector := labels.SelectorFromSet(map[string]string{"knative.dev/pipelinerun": key})
taskRuns, err := c.taskRunLister.TaskRuns(namespace).List(selector)
if err != nil {
c.Logger.Errorf("Error retrieving TaskRuns by label for %s", key)
} else {
for _, tr := range taskRuns {
c.Logger.Infof("THIS IS MY TASK RUN %v", tr.GetName())
}
}
OwnerReferences
As far as I can tell it's not possible to query for all objects with a particular owner reference. I found these two thread requesting this feature:
- kubernetes/kubernetes#54498
- kubernetes/kubernetes#49387 (comment) (requests via FieldSelectors)
Which is unfortunate since this is pretty much exactly what we're looking for!
ObjectReferences
I completely forgot that in our PipelineRun
schema, we actually already have references to the created TaskRuns:
The go type is a bit incomplete, but in the yaml you can see what we were getting at:
Names
- Since
TaskRuns
andBuilds
have a 1:1 mapping, it probably makes sense to use the same name for both - In
PipelineRuns
, we can construct a deterministic name by combining the name of thePipelineRun
and the name of theTask
inside the referencedPipeline
So we could query for the child resources by name, though it seems that fuzzy or regex based searching isn't clearly possible (apparently kubernetes/kubernetes#9248 (comment) that's what labels are for 🤣) - even though it is actually supported by the describe command.
@tejal29 pointed out there is some complication here tho - what do we want to do if the same PipelineRun
or TaskRun
(i.e. with the same name) is invoked? To work around that we could add a random element to the names, or alternatively we could require the Runs have unique names.
Conclusion
I suggest that when retrieving child resources in the PipelineRun
controllers, we use references to TaskRuns
in the Status
, since we'll need those anyway (the controller will need to know which it has started).
I think sticking to using the same name for the TaskRun
and its child Build
(which @aaron-prindle is already doing).
But as @pivotal-nader-ziada pointed out, it can be handy for the controllers when logging to know about what created them, and @tejal29 also pointed out it's handy on the command line to retrieve all related TaskRuns
for example, so I think we should add:
PipelineRun
:knative.dev/pipeline
- can added byPipelineRun
controller
TaskRun
:knative.dev/pipeline
- if this was triggered by aPipelineRun
, the related pipelineknative.dev/pipelineRun
- if this was triggered by aPipelineRun
Build
:knative.dev/pipeline
- if this was triggered by aPipelineRun
, the related pipelineknative.dev/pipelineRun
- if this was triggered by aPipelineRun
knative.dev/taskRun
- if this was triggered by aTaskRun
(even tho the name will be the same)
I'll add these to the existing controllers as they get to the point where they can be added, unless they are added by folks working on those controllers before I get a chance.
(let me know if you want any more added!)
from pipeline.
I'm gonna unassign myself from this since I haven't gotten a chance to work on it: the work to do here is to add the labels as described in the previous comment.
from pipeline.
/assign @tanner-bruce
from pipeline.
Related Issues (20)
- Access `reason` from the execution status of a `taskRun` in `finally`
- Helm chart outdated HOT 3
- Overriding Pipeline timeout does not work HOT 2
- Additional unit tests are needed for Kubernetes native sidecar support HOT 2
- Remote resolvers fail to save ECR cache
- The spec fields of TaskRun and PipelineRun can still be modified during execution
- Allow modify the spec of a PipelineRun when it is in the `PipelineRunPending` state
- A mechanism to remotely obtain runtime parameters of `TaskRun` and `PipelineRun` HOT 4
- Add support for `when` within `matrix.include`. HOT 3
- It is not possible to have the webhook controller _not_ use TLS HOT 1
- No variable substitution when using matrix and array the length of 1
- pipelinerun-with-when-expressions HOT 2
- TaskRun pod should have UUID label of Taskrun HOT 1
- The TaskRun did not fail promptly after the Pod experienced OOM
- Cancelling an active PipelineRun with TaskRuns that are already complete hits "PipelineRunCouldntCancel" condition on v0.62.0 HOT 1
- Enable securityContext field for affinityassistant podtemplate
- pprof profiling does not work with tekton-pipelines-controller deployment HOT 2
- Set container level securityContext for Affinity assistant HOT 1
- Add new feature flag to set readOnlyRootFilesystem for pipelinerun, taskrun and Affinity assistants containers HOT 1
- default resource requirements should be executed before LimitRange transformer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pipeline.