-
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
Initial design ideas for Source #39
Conversation
Name string `json:"name"` | ||
Type string `json:"type"` | ||
URL string `json:"url"` | ||
Branch string `json:"branch"` |
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.
Revision
?
In Build's GitSource
today, we decided to accept branches, tags and arbitrary refs (including commits) in the same field, using Git's built-in semantics.
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.
make sense to be consistent
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.
Few tips:
We probably define interface Source
method Type
.
// SourceType defines a source type for all source
type SourceType string
var Git SourceType "git"
var Svn SourceType "svn"
type Source interface {
Type() SourceType
Version() string
// Pulls source code.
Pull(copyLocation string) error
// This combines a bunch of fields and then displays the source location
// e.g. in case of git, it will be github url while in case of svn it will be a svn url etc.
Location() string
}
And Then the GitSource
can define its own fields like you have and implement methods
func (gs GitSource) Version() string {
return gs.Commit
}
func (gs GitSource) Type() SourceType {
return Git
}
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.
That ways, other sources can be added easily
|
||
func (s GitSource) getParams() []Param { | ||
var result []Param | ||
return result |
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.
return []Param{}
?
These could also be written on single lines to conserve vertical space:
func (GitSource) getParams() []Param { return []Param{} }
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 really should also be returning the actual values of any existing Params
This is a cool idea, and more like some of the coolness that concourse has - it makes a lot of sense, since the line between the two is so fuzzy anyway e.g. images could be either inputs or outputs.
Interesting!! So this would actually tackle #11 as well. It seems like this changes the model a bit: instead of passing a I feel like this makes the model a bit more complicated: we now have one more way of expressing the DAG (nextTask, prevTask, paramBindings AND passedConstraints), unless there's a way we can do away with paramBindings completely and replace them with passedConstraints? I'm not completely seeing the advantage of using passedConstraints over using paramBindings. Would be helpful to see a list of pros and cons of both!
Do you have any thoughts about what one would do if they wanted to extend this model? I guess it would require rebuilding the controller, but you could extend it with anything that complies with the interface? As we move forward it would also be great to see what this looks like in a TaskRun (e.g. the kritis task run) My main questions:
|
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// SourceVersion is the Schema for the sourceversion API |
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.
maybe a bit here about how a SourceVersion
would be intended to be used?
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.
SourceVersion is for the taskrun_controller
to make sure the same version of the Source (eg: git commit) is used across the same pipeline run, will update the comment
} | ||
|
||
func (s GitSource) getVersion() string { | ||
return s.Commit |
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.
ah cool, so anything could have a version potentially, and for a git source, it happens to be the commit - pretty cool!
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.
yeah, exactly, it will mean different things for different types
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.
+1
Just a note, lets lock down a Source interface and then GitSource implement the interface.
Name string `json:"name"` | ||
// TODO: maybe an enum, with values like 'registry', GCS bucket | ||
Type string `json:"type"` | ||
URL string `json:"url"` |
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 it would maybe be useful to separate the endpoint where the image is tored from the URL - we might want to have an endpoint, tag, and sha all available somehow
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.
Thats would be the metadata for image source. We could consider adding metadata
for source's interface to provide this information.
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.
How about we use the subset of fields Redhat Atomic Host Signature. https://github.com/aweiteka/image/blob/e5a20d98fe698732df2b142846d007b45873627f/docs/signature.md
"identity": {
"docker-reference": "busybox"
},
"image": {
"docker-manifest-digest": "sha256:a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6"
},
Some Missing fields are "Registry"
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.
docker-reference
could be combination of registry:docker-image-name
as well.
examples/pipelines/kritis.yaml
Outdated
sourceKey: kritis | ||
params: | ||
- name: testArgs | ||
value: "-e REMOTE_INTEGRATION=true" | ||
sources: |
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.
in the current design, this would make sense to put into the PipelineParams, i.e. replacing these sources in the example
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 wanted to make them outside of the tasks
so it can be used across multiple tasks, but it would work either outside or in the PipelineParams
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 we'd definitely want this in PipelineParams, unless we decide in the long run to do away with PipelineParams
} | ||
|
||
// SourceRef can be used to refer to a specific instance of a Source. | ||
type SourceRef struct { |
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.
So is SourceRef
the interface that Sources
must comply with? Would a SourceRef
be expected to have the functions that the git + image types above have? e.g. getVersion
?
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 so :)
yes images can be either inputs and outputs, maybe the name
Like you said this would address #11 as well to make it easier for the code to track which Source is moving along between tasks in a PipelineRun
You would have to declare any
you are correct, we might not need the ParamBinding, the reason I added the passedConstraint is that it makes the dependency of artifacts more explicit, didn't know how ParamBindings can do that?
Not sure if we have to add something, but I though anything that implements the interface should work, I can try it out
will work on some more examples of the pipeline yaml to demonstrate it more
yes, each image needs a Source This PR is just to start the conversation about the We are open to any modifications we come up while working on this together |
Adding to @pivotal-nader-ziada's point about the advantage of For example
It provides information that task
WDYT? @pivotal-nader-ziada @bobcatfish @imjasonh |
Branch string `json:"branch"` | ||
Commit string `json:"commit,omitempty"` | ||
ServiceAccount string `json:"serviceAccount,omitempty"` | ||
type Source interface { |
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.
Ah i see you have defined Source interface here.
getType() string | ||
getParams() []Param | ||
getVersion() string | ||
getPassingConstraints() []TaskRef |
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.
Can you add more information on this method?
getPassingConstraints()
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.
good catch, that should not be here. We first thought about putting the constraint about a Source being passed from one task to another here, but moved it to SourceBinding. Missed removing it from here. Where do you think is a better place for that?
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 feel, getPassingConstrainsts
should be defined at the interface level.
The reason being, for each source type, they are going to be constant. You can multiple sources of same source type defined in your cluster. You do not want to repeat the binding information for each sourcebinding.
Does that make sense?
Thanks for putting in those examples @shashwathi , those really help make the ideas more clear!
I don't quite agree with this b/c I think the test code should be versioned along with the code it is testing and it would be very confusing to have a different commit's test code running. The simplest would be to use the same version of the test code as the application code, and so my feeling is that by default a
I agree! It's interesting that you have to declare all your sources up front as well, which I think provides more clarity, e.g. in the previous kritis example halfway through the pipeline there's suddenly this image being passed around, but if you just glance at the pipeline you have no idea it's producing image. I think your suggestion is a definite improvement here!
Interesting! So it seems like we could potentially replace Would it be possible to use |
we will work on updating the PR with all the comments and adding a README with examples |
Sounds great, thanks @pivotal-nader-ziada !!
Quick update that @shashwathi brought to light some really important usecases here, e.g. in a super long running pipeline you need to make a change to a repo, e.g. a test, and don't want to have to re-run the whole thing. |
What would be the use case for this? |
It's hard to think of a good one, but here's the best that I've got: maybe you want to send a slack notification (via a Task) after a Task has run, e.g. after the integration tests pass, you send the message? On the other hand, from today's discussion it sounds like we probably want to create some kind of notification specific design 🤔 so maybe this is a bad example. |
@shashwathi @pivotal-nader-ziada after thinking a bit more about our discussion on Friday, I've created a couple follow up issues: #49 - Designing notifications After thinking more about the usecase where user wants to update a source needed by a long running Pipeline as the Pipeline is executing, I am thinking:
|
We (myself and @shashwathi) are in sync with the idea @imjasonh explained in our discussion that a |
That's reasonable @pivotal-nader-ziada - I'm fine with assuming that we'll avoid longer running pipelines for now, and revisiting this later. What do you think @imjasonh ? I'm fine with resolving #50 as won't fix for now, we could always bring it back later if we need it. |
Added values for the following types, which would be the initial types we would want to implement and support (could expand to support more in the future): - `SourceType` - `ArtifactType` - `ResultTargetType` - `PipelineTriggerType` and `TaskTriggerType` - `ParamType` (just strings for now?) Since in #39 @pivotal-nader-ziada and @shashwathi are combining Sources and Artifacts into one concept, we'll likely combine `SourceType` and `ArtifactType` into one type as well. While doing this noticed and cleaned up a couple things: - Don't need to specify lists of result stores, just one for each type (test, log, runs). Also these are identical except for their usage, so we can use a common type for all of them - Turns out pipeline run specs were not defined! - Updated DEVELOPMENT.md re. how to regenerate generated code (such as `zz_generated.deepcopy.go`) Fixes #18
If nobody needs #50 now then I'm okay with thinking about it more later, but I still think we'll need it eventually. 👍 |
Added values for the following types, which would be the initial types we would want to implement and support (could expand to support more in the future): - `SourceType` - `ArtifactType` - `ResultTargetType` - `PipelineTriggerType` and `TaskTriggerType` - `ParamType` (just strings for now?) Since in #39 @pivotal-nader-ziada and @shashwathi are combining Sources and Artifacts into one concept, we'll likely combine `SourceType` and `ArtifactType` into one type as well. While doing this noticed and cleaned up a couple things: - Don't need to specify lists of result stores, just one for each type (test, log, runs). Also these are identical except for their usage, so we can use a common type for all of them - Turns out pipeline run specs were not defined! - Updated DEVELOPMENT.md re. how to regenerate generated code (such as `zz_generated.deepcopy.go`) Fixes #18
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.
Overall i think this LGTM,
The only concern i have is with passingConstraint should be a source implementation detail and should be hidden to users in config.
To make the config easier, we can also drop inputSourceBindings
and outputSourceBindings
and just havesourceBindings
. We should be able to use @aaron-prindle templating work to identify the names.
e.g.
- name: push-kritis
taskRef:
name: build-push
sourceBindings:
- name: $inputs.sources.workspace
sourceKey: kritis
- name: $outputs.artifacts.registry
storeKey: stagingRegistry
builtImage: kritis
Sorry @shashwathi jumping on this late.
Maybe we all (at least i am not :) ) are not on the same page what I feel |
@pivotal-nader-ziada and @shashwathi can go into more detail but I understood
Re. (1) my preference is that we should always use the same version of the Source/Resource regardless, but I think that (2) is cleaner than what we had before, and @shashwathi 's exmaple in #39 (comment) shows how it can be used for both fan in and fan out
Interesting idea! At the moment, |
We are working on applying all the comments and adding examples that will make things more clear, coming soon (today)
yes, exactly, passed constraint would replace nextTask and prevTask and be used to drive the fan in and out as @bobcatfish explained above I think the |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
/check-cla |
In favor of replacing nextTask, prevTask by one keyword. I was playing with srewdriver.cd other day and i was going to propose Just note, its implicit that we pass on the versions and sha of source built by a upstream task to downstream task. We can start the pipeline at any stage, but from there on, the next tasks use the source code at version built by prev task.
Works! |
/hold cancel |
everything looks good from our side, can you take a look if we missed anything and approve again since we had a new commit we can add follow up issues for more changes Thanks |
type: image | ||
params: | ||
- name: url | ||
value: gcr.io/wizzbang-staging |
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.
cool, i like that this is separate!
name: wizzbang | ||
- name: wizzbangStagingImage | ||
resourceRef: | ||
name: wizzbangStagingImage |
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 that this reference belongs in the PipelineRun
, since that would be the place where you'd bring everything together (otherwise everytime you use this Pipeline, you have to use the same resources). but we can iterate on this!
Looking good! I'm going to lgtm this so we can go ahead and merge it :D /lgtm Thanks for fixing up the author issues @pivotal-nader-ziada , sorry about that :( now it looks like @shashwathi isn't officially an author of any commits :'( How much does this interfere with your workflow? I want to follow up about this internally. Is there any chance you'd consider making use of something like github's co-author feature? |
Oh I'm also going to hit "update branch" |
/lgtm NOTHING REALLY CHANGED @knative-prow-robot CMON |
Yeah we can try github co-author next time. |
I know we added support for GitHub co-author to our CLA checker, but I actually think it'll run into the same problem... it'll still complain about needing consent of the secondary author. We can handle this case of different author and committer (or even co-author) when the two individuals are covered by the same CLA. In fact, I'm pretty sure it was for Pivotal specifically that we added this feature. I'll follow up privately to get some more information and try to debug what happened here. In this case in particular, there might be an easy fix. However, this is a use case we need to handle in the general case as well, but that's going to take a bit more time. |
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
- name: revision | ||
value: master | ||
- name: url | ||
value: https://github.com/grafeas/kritis-test |
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 repository does not seem to exist. Was it subsequently deleted? Or not publicly readable?
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.
funny you should mention this, i just noticed it myself! in #217 it's being updated to use a repo that exists - I think this was supposed to be an example of a case where someone has decided to put their tests in a separate repo (not something I'd recommend!)
* initial design ideas for source * changes to implement Resource concept * remove extra function in resource interface * Update JSON struct tag to pass go vet * changes to make tests work * minor readme changes * remove resource ref, update configs and samples * Add resources as CRD * Rename task inputs & outputs
We ended up in a state where we had both an `examples` dir and a `samples` dir, and neither were tested, so both were slightly out of sync with each other and the actual types. This was b/c: - When we used kubebuilder, we generated our types from an original set of examples - previously these were in `config/samples` and they ended up in `samples`. We used the validation tests generated by kubebuilder to test these, but when we removed kubebuilder we removed the tests - Before presenting the API to the Build CRD working group, we wanted to have some more complex, real world examples, which @tejal29 created from the `kritis` project and the k8s guestbook example This commit makes sure that all of the functionality demonstrated in `samples` is in `examples`, and removes `samples`. This included: - Fixing `passedConstraints` to be plural as the types expected - Including references to the `PipelineParams` in the `TaskRun` example (removing the duplicated list of result endpoints, since we'll be getting this from the references instead) - Fixing clusterBindings to refer to the actual names of the clusters involved It also adds a step to the integration tests to deploy the examples, which will fail if they do not match the expected schema. At this point they are torn down immediately after creation, but in #108 we can expand this to actually test that they are working. Also had to make some tweaks to the types: - actually including `ClusterBindings` in the `Pipeline` - Using names which include `Resource` instead of `Source`, which we moved away from in #39 Fixes #20
Signed-off-by: Shash Reddy [email protected]
Design proposal for #11 #12 and #13
Proposed Changes
git
andimage
implementation of SourcepassedConstraint
to make sure a task uses the Source Version that passed a previous taskThis PR is just to gather feedback about these design ideas.