-
Notifications
You must be signed in to change notification settings - Fork 15
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
SHIP-0031: Shipwright Trigger #68
SHIP-0031: Shipwright Trigger #68
Conversation
/retitle SHIP-0031: Shipwright Trigger |
@otaviof: GitHub didn't allow me to request PR reviews from the following users: ricardomaraschini. Note that only shipwright-io 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. |
ships/0031-shipwright-trigger.md
Outdated
spec: | ||
source: | ||
url: https://github.com/otaviof/nodejs-ex.git | ||
trigger: |
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.
What about making this a resource on its own? IIUC the way things are designed here it seems like we would be introducing fields to the Build
struct that would be meaningful only to this new trigger
project (or operator/controller if I may).
This is just food for thought: what about having a new type called BuildTrigger
that refers to a Build
by its name and then have this new type living only in the new trigger
repo ? I am pretty new to the project so please educate me on why this is not a good idea.
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.
What about making this a resource on its own? IIUC the way things are designed here it seems like we would be introducing fields to the
Build
struct that would be meaningful only to this newtrigger
project (or operator/controller if I may).
There's an intimate relationship between the Build
resource and the Git repository itself. For instance, for GitHub WebHook you can employ a shared secret between the repository and the Shipwright Build, in order to validate the caller, increase security.
So, the attribute .spec.trigger.secretRef
can be unique per Build
, and in case it's shared between more resources, it would be shared via the Secret
resource (name).
The .spec.trigger.when[]
could be common for more Build
resources, indeed. However, I still look at it as means to trigger that specific Build
, so once again an "intimate relationship".
ships/0031-shipwright-trigger.md
Outdated
|
||
### Security Model | ||
|
||
The security model is enforced by only allowing the Shipwright Trigger to have the [least amount of permissions as possible](https://github.com/otaviof/shipwright-trigger/blob/main/deploy/200-role.yaml). The new application will have to watch over Shipwright Build, BuildRun, Tekton PipelineRun and Run. |
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.
Missing Image
here ?
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.
We might as well say all the resources involved with the Shipwright Trigger controllers. And for the record, I still need to prototype the Image
controller, we could explore this together if you're interested.
tektoncd/community#523 Custom Tasks Graduation |
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 write-up.
ships/0031-shipwright-trigger.md
Outdated
- name: for push directly on the main branch | ||
type: Push | ||
branches: | ||
- main |
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 like the pragmatic simplicity here. I think we cover the 99.9 % use case by assuming that there is exactly one Git source (not sure if we ever allow anything else anyway) as I guess we take the repository URL from the source?
Regarding the branches. Is that mandatory? If not providing it, would it take the revision from the source as default? If the branch here is not the source revision, then the BuildRun will need to override this.
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.
FWIW the separation of branch references from source revision, context dir, etc. is what was done with the openshift build API.
https://github.com/openshift/api/blob/76ab2e0a141066de3550b89e7376783ae8d2c8b9/build/v1/types.go#L445 and https://github.com/openshift/api/blob/76ab2e0a141066de3550b89e7376783ae8d2c8b9/build/v1/types.go#L600 for reference
Having to specify a branch for certain should NOT BE mandatory. OpenShift Builds has worked that way since day one.
A comment or footnote making that clear feels warranted @otaviof
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 like the pragmatic simplicity here. I think we cover the 99.9 % use case by assuming that there is exactly one Git source (not sure if we ever allow anything else anyway) as I guess we take the repository URL from the source?
Thanks! I think the same API semantics will work for more than a single Git source, given the WebHook event carries on the Git repository references. Based what's provided the WebHook payload we can find all the Builds referring to it.
Note that we may have more than a single Build
referring to the Git respository, and therefore the search needs to take the actual triggers in consideration.
Regarding the branches. Is that mandatory? If not providing it, would it take the revision from the source as default? If the branch here is not the source revision, then the BuildRun will need to override this.
Yes, I think that's a good solution! It also matches what @gabemontero brought up, based on how OpenShift works.
ships/0031-shipwright-trigger.md
Outdated
- name: watching over the base-image | ||
type: Image | ||
images: | ||
- ghcr.io/some/base-image:latest |
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 scenario is important, but is mentioned the first time here while not mentioned in the motivation, or goals. Later there are more details that this works only for images that are managed by the shp image controller.
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.
Sure! I'll add that up on the goals and more information about the future plans to integrate with Image.
ships/0031-shipwright-trigger.md
Outdated
|
||
The trigger is defined directly on the `Build` resource, and when the attribute is empty it means the given `Build` resource is not subject to triggers, as expected. The new `.spec.trigger` attribute is structured as follows: | ||
|
||
- **<code>.secretRef.name</code></strong>: local reference to a Secret object, containing pre-defined keys to share an [secret-token](https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks#setting-your-secret-token) between Git service providers and local <code>Build</code> instances; |
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.
The secret token is GitHub specific. Is directly below trigger a good location or should it be in the when(s) that are Git source related?
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.
The WebHook shared secret is directly related to the Git repository itself, so maybe we could avoid adding that under .spec.trigger
and let it be part of .spec.source.credentials
.
Currently, it looks for a predefined key (github-secret
). What do you think about merging this with .spec.source.credentials
secret?
|
||
An essential part of the developer experience is to be able to commit and push code changes, while rest assured that will actionate automation procedures to produce a new container image. | ||
|
||
As well as, being able to combine the image creation process with Continuous Integration pipelines, and watch over Tekton Pipelines which may be producing dependencies and other artifacts used on container images built by Shipwright. |
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.
For the Tekton Pipelines watch based trigger, I am looking for a good scenario. EDIT: I read what you have later, but I am still not seeing a good use case. If I would have to chose between a Tekton pipeline that does unit tests, completes, and then a BuildRun starts; or a pipeline that does unit tests and then has a custom task for the shipwright build, then I would always use the latter option.
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 hope that yesterday's community meeting we've been able to discuss about this scenario, let me know if the use case needs to be more descriptive on the EP.
|
||
# Proposal | ||
|
||
Introduce a new project name Shipwright Trigger (`shipwright-io/trigger`) to based on the rules defined on the Build resources, listen to WebHook events coming from Git service providers, incorporate Shipwright into Tekton via `CustomTask` (Tekton Run resource), and watch over Tekton Pipeline resources in order to trigger `BuildRun` resources accordingly. |
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 lover that we introduce our own webhook handler instead of trying to somehow make this working with Tekton Triggers. It will be much simpler like that for our users.
ships/0031-shipwright-trigger.md
Outdated
} | ||
``` | ||
|
||
Internally, we will differentiate the service provider based on the [pattern](https://pkg.go.dev/net/http#Handle), the request URL path, and therefore we can allow users to configure which pattern will respond for a given Git service provider requests. |
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 please elaborate more the configuration need here? A simple solution would be that our service has a /github endpoint for GitHub and eventually /gitlab for GitLab etc.
ships/0031-shipwright-trigger.md
Outdated
|
||
#### Shipwright Build Controller | ||
|
||
The Builds are added or removed from the Inventory through the [Build Controller](https://github.com/otaviof/shipwright-trigger/blob/main/pkg/trigger/controllers/build_controller.go), responsible to reflect all Shipwright Build resources into the Inventory. On adding new entries, the Build is prepared for the subsequent queries. |
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.
As mentioned earlier, I do not think that the term controller is suitable here because we do not do anything (beside caching) when some Build changes. On the other hand, Tekton Run is really a controller because we do something (setup BuildRun, update Run status).
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'm borrowing the term "controller" from Kubernetes, as in a actor which watches over a resource moving it to the desired state. In this case the so called "Build Controller" is watching over Builds
and feeding the Inventory... what do you think would be a more suitable name to 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.
Made a few initial comments @otaviof
I wouldn't say this is a full review on my part, since I believe you have changes pending from @SaschaSchwarze0 's comments, some of which lined up with ones I was thinking of, and you might have a big enough change coming that it would be prudent to cycle through it again after that.
In particular, I'm curious on where you go with my "triggered by" comment, and the ripple effect it has.
ships/0031-shipwright-trigger.md
Outdated
|
||
# Alternatives | ||
|
||
None. |
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 some explanation and detail on why we are not going with Tekton Triggers is warranted here. Folks outside of our circle who have not been part of our video conferences or slack discussion quite possibly are going to ask that question, and should be able to discover our rationale here.
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.
Indeed! I'm using the initial work done on #41 as input to explain what we've spoken, so please consider the latest update.
ships/0031-shipwright-trigger.md
Outdated
- name: for push directly on the main branch | ||
type: Push | ||
branches: | ||
- main |
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.
FWIW the separation of branch references from source revision, context dir, etc. is what was done with the openshift build API.
https://github.com/openshift/api/blob/76ab2e0a141066de3550b89e7376783ae8d2c8b9/build/v1/types.go#L445 and https://github.com/openshift/api/blob/76ab2e0a141066de3550b89e7376783ae8d2c8b9/build/v1/types.go#L600 for reference
Having to specify a branch for certain should NOT BE mandatory. OpenShift Builds has worked that way since day one.
A comment or footnote making that clear feels warranted @otaviof
|
||
![Shipwright Trigger WebHook Schematics](assets/0031-shipwright-trigger-webhook.drawio.png) | ||
|
||
The start of the workflow (1) is at the Shipwright Trigger instance, it will be watching over `Build` objects using a regular Kubernetes Controller. Since the Trigger Controller is aware of all `Build` instances, it creates an inventory of `Builds` carrying trigger rules (`.spec.trigger` attribute), and therefore, it's able to search for `Build` objects. The Trigger will only start listening for WebHook requests when the controller has synchronized, so it has the inventory full beforehand. |
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 I was trying to figure out where status was being managed, and then noticed @SaschaSchwarze0 's comment here.
It would not be in this piece of function you are describing here per se, but again, I was not sure where to put my comment, but as it had some synergy with @SaschaSchwarze0 's ....
I was expecting either new conditions or fields in status (I don't have a strong opinion either way) that captured that his BuildRun was "triggered by" either a webhook, image change, pipeline completion, etc. Analogous to the various trigger by semantics OpenShift Builds has in its BuildRequest: https://github.com/gabemontero/api/blob/f60a0b2883eae330c01d294b3eba2ee9c3fe7a47/build/v1/types.go#L1236-L1269
Also I'm not seeing anything along those lines in https://github.com/shipwright-io/build/pull/1008/files
4f43977
to
afe0794
Compare
Hi @otaviof, nice feature! I have a few questions:
thanks. |
afe0794
to
1e96e75
Compare
Sure! I just modified the Tekton Custom-Tasks section to reflect a real world example, please let me know if it's clear of how the parameters are transferred from the
That's a great idea! Would you have pointers of how such integration works in ArgoCD? Thanks in advance 👍 |
Hi @otaviof , the example looks good. For ArgoCD, one is a custom trigger for shipwright: https://argoproj.github.io/argo-events/sensors/triggers/build-your-own-trigger/ Another is just like tekton pipeline, to trigger Build by an Argo workflow. https://argoproj.github.io/argo-workflows/workflow-templates/ apiVersion: shipwright.io/v1alpha1
kind: Build
spec:
trigger:
when:
- name: nodejs-ex workflow has succeeded
type: Workflow
objectRef:
name: nodejs-ex
status:
- Succeeded For custom task, I didn't see the similar concept. But that's good enough already. |
|
||
Upon the creation of a `BuildRun` instance, the `PipelineRun` object is labeled for the controller to be able to avoid reprocessing. | ||
|
||
### WebHook Handler |
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.
For the record, GitHub sends Actions Workflow events on the same WebHook channel. The design on this proposal is able to support such type of events as well.
Thanks for the suggestion, indeed the Please consider the contact information, we send the meeting invites on the mailing lists. |
1e96e75
to
f48470e
Compare
Please consider the latest chances, I've added a |
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 progress on the Trigger Cause stuff @otaviof
add a couple of comments around yaml based examples
ships/0031-shipwright-trigger.md
Outdated
|
||
Those relevant attributes will be codified as `BuildRun` labels, following a predetermined structure on which the Build Controller is able to make use of. The Build Controller, the owner of `Build` and `BuildRun` resources, will then translate the information from the labels to properly structure status fields. | ||
|
||
The trigger cause must be part of a status condition showing the exact reason and context. |
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.
put together a yaml snippet to illustrate this
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.
Please consider the last changes.
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.
OK I don't see any yaml for this point on status and conditions @otaviof
I was expecting, to go along with your yaml examples above, something like
a new constant for condition type like
Triggered Type = "Triggered"
and then
apiVersion: shipwright.io/v1alpha1
kind: BuildRun
...
status:
conditions:
- type: Triggered
status:
reason:
message:
To go along with your statement "The trigger cause must be part of a status condition ..."
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 should be resolve as per: https://github.com/otaviof/community/blob/467cea4c797411ecfcc8e57facf7495b434cd15b/ships/0031-shipwright-trigger.md?plain=1#L297-L301, please consider.
f48470e
to
bf1b4a3
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.
/approve
ships/0031-shipwright-trigger.md
Outdated
- **`.when[].branches[]`**: slice of branch names for the current repository, branch names where a Build should be activated in case of `Push` or `PullRequest` event. When not informed, it will adopt the attribute `.spec.source.revision` instead; | ||
- **`.when[].images[]`**: slice of image names to watch, when those are updated a new Build is activated; | ||
- **`.when[].objectRef`**: used in conjunction with `Pipeline`(type), and describes a local Tekton Pipeline instance and its current status; | ||
- **`.when[].objectRef.name`**: when informed, the Pipeline is directly search by its name; | ||
- **`.when[].objectRef.status[]`**: slice of Tekton Pipeline [status names][tektonPipelineRunStatus] where a new Build should be activated. For instance *"Succeeded"*; | ||
- **`.when[].objectRef.selector{}`**: a map of label key-value entries, a alternative to the `.objectRef.name` attribute, the Tekton Pipeline resource will be identified by label matching; |
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 recommend that we have separate API objects for each trigger type:
.when[].pullRequest.branches[]
.when[].image.images[]
.when[].pipeline.name
This lets us employ type discriminators and add validation to the API (ex - the Git
trigger type should not have any objectRef
values)
I won't block merge on this - we can discuss in further detail when the full API is implemented.
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 tend to agree. We do this now with volumes where we inherit the Kubernetes VolumeSource. And imo that's also what we should go to with spec.sources
in our future API evolvement.
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 recommendation, @adambkaplan. I've adjusted the EP accordingly, and as well the prototype changes. Please consider.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan 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 |
I have created a GitHub discussion so we can think beyond this proposal. It is clear that we will want more mechanisms to trigger builds. Therefore, I would consider this proposal a "first attempt", where we should feel free to experiment and alter the API as we learn from experience. Let's continue to develop these ideas in #75. |
ships/0031-shipwright-trigger.md
Outdated
- **`.when[].branches[]`**: slice of branch names for the current repository, branch names where a Build should be activated in case of `Push` or `PullRequest` event. When not informed, it will adopt the attribute `.spec.source.revision` instead; | ||
- **`.when[].images[]`**: slice of image names to watch, when those are updated a new Build is activated; | ||
- **`.when[].objectRef`**: used in conjunction with `Pipeline`(type), and describes a local Tekton Pipeline instance and its current status; | ||
- **`.when[].objectRef.name`**: when informed, the Pipeline is directly search by its name; | ||
- **`.when[].objectRef.status[]`**: slice of Tekton Pipeline [status names][tektonPipelineRunStatus] where a new Build should be activated. For instance *"Succeeded"*; | ||
- **`.when[].objectRef.selector{}`**: a map of label key-value entries, a alternative to the `.objectRef.name` attribute, the Tekton Pipeline resource will be identified by label matching; |
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 tend to agree. We do this now with volumes where we inherit the Kubernetes VolumeSource. And imo that's also what we should go to with spec.sources
in our future API evolvement.
|
||
The GitHub support is based on a common interface, on which we will support more service providers in the near future, like for instance GitLab and others. Therefore, the interface semantics must be able to implement the following use cases: | ||
|
||
- Parse the WebHook request payload identifying the specific type of event |
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.
An alternative would be that we serve different paths for each vendor that we support, /event/github
vs /event/gitlab
. For usability reasons, it might make sense if we also extend the status of the Build. It will probably be impossible to (always) determine the externally exposed URL of the service especially if it's not just the Ingress but cluster-external components route requests. So, we will need a configuration option where we are told about it. But then we can use that and put the URL of the endpoint into the Build status from where the user who created the Build can copy it into the GitHub / GitLab etc UI.
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.
we handle it in the same fashion as @SaschaSchwarze0 describes with openshift builds and that has proven maintainable / successful
+1
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.
Let me clarify this point a bit better, @SaschaSchwarze0. The need to parse the GitHub event is to determine which exact event is in the request, as you can see on the GitHub WebHook documentation there are a number of those.
So, in one hand, we always need to parse GitHub WebHook request payloads, but in the other we can easily extend the triggers support to more intersting use-cases, like for instance GitHub Actions Workflow.
An alternative would be that we serve different paths for each vendor that we support,
/event/github
vs/event/gitlab
.
That's the current proposal, Sascha. Indeed, we can extend the WebHook endpoints by support different request patterns differentiating providers like GitHub, GitLab, etc.
For usability reasons, it might make sense if we also extend the status of the Build.
Yes, most defintely 👍 And it's also part of the current proposal, suggested by @gabemontero early on.
It will probably be impossible to (always) determine the externally exposed URL of the service especially if it's not just the Ingress but cluster-external components route requests.
The external endpoint URL is responsibility of the cluster administrator, this persona will know in advance the desired URL and create the necessary configuration to expose Shipwright Trigger.
I touched this subject as part of the Risks and Mitigations section which describes the different ways of bringing external traffic into the cluster. For instance, the Ingress Controller as you mentioned, also options like service mesh and OpenShift routes.
So, while the Shipwright Trigger won't be able to know the exact URL, in order to determine the exact circumstance the WebHook request was issued, GitHub offers a very good amount of information to determine repository, originating user, and a lot more.
In other words we need to extend to work invested on parsing the request payload to extract more meta information needed.
So, we will need a configuration option where we are told about it. But then we can use that and put the URL of the endpoint into the Build status from where the user who created the Build can copy it into the GitHub / GitLab etc UI.
Given the security implications explained before, the persona responsible to expose the cluster for external requests will provide the final URL. On this video you can see how the configuration would happen.
ships/0031-shipwright-trigger.md
Outdated
|
||
Whenever a `BuildRun` is issued by the Shipwright Triggers, it must register all the relevant attributes that caused it. The relevant attributes must be able to identify the which trigger inside the `.spec.trigger.when[]` slice, plus the context obtained from the WebHook request and from the Kubernetes resources watched. | ||
|
||
Those relevant attributes will be codified as `BuildRun` labels, following a predetermined structure on which the Build Controller is able to make use of. The Build Controller, the owner of `Build` and `BuildRun` resources, will then translate the information from the labels to properly structure status fields. |
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 these labels will also need to change the behavior of the BuildRun:
- when there is a trigger for a PullRequest, then the repository and revision (commit ID of the PR) will need to be passed to the source step.
- when there is a trigger for a Push, then the revision (commit ID that was pushed) will need to be passed to the source step.
- when there is a trigger for an Image, then I could imagine that the user will want this image to make it somewhere. This is not trivial because it depends on the strategy. For
ko
, I would want to do agoml set -f .ko.yaml -p defaultBaseImage -v THE_IMAGE_THAT_TRIGGERED
. In a Dockerfile, I would want to pass it as a build-arg. So, we need maybe some strategy enhancements to support this. And we need to brainstorm how we can pass this.
While the Image part is probably for the future, we likely need the Git related things already at the beginning.
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.
interesting point @SaschaSchwarze0 ... I wonder if some further clarification is needed though as I read you text ^^.
I say that because if one wants to change behavior, then generally in k8s you should use annotations for that vs. labels ... annotations are the more loosely coupled alternative to API change for controlling implementation behavior, where labels are metadata/useful information stored by the implementation when it is finished its intent,
like what @otaviof mentions in this section. So your labels will also need to change the behavior of the BuildRun
gave me some pause.
For example, the type of trigger matters, and the type of trigger might lead to different labels being set (git commit vs. image sha, etc.). I could see that.
But then, if we have a "chain" of build runs that manifest from one build run leading to another build run getting triggered, that gets interesting. Do we want shipwright interpreting labels from prior build runs in the chain and adjusting behavior? Is that what you were thinking also? Initially, that seems to not mesh with the k8s annotation vs. label convention.
But may I'm incorrectly reading in between the lines with what you intended.
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.
Hi @gabemontero, I was not so much looking at the label vs annotation aspect. But yeah, labels, also because of their length limitation could become a problem and annotations might be more correct - or some first-class fields of the BuildRun are used instead, but then it might be not obvious when they come from a user vs a controller (though not different to annotations that could also be user-defined).
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.
ok thanks for clarifying @SaschaSchwarze0
also, good point on the label length restrictions, especially in the light on long'ish items like image or commit sha's; something the implementation would minimally have to be cognizant of
I wonder @otaviof if the explicit field vs. label vs. annotation back and forth here should be captured as an open question. I at least would be fine classifying it as such, merging this SHP with that, and then sorting this our during the implementation PR. But of course let's see what sort of consensus arises as others chime in. Perhaps a discussion topic for an upcoming community meeting.
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.
@SaschaSchwarze0, @gabemontero as we've spoken during the community meeting yesterday (#80) about the objective of passing information via labels, we have a couple o paragraph to summarize the objective with them. Please consider:
Let me know if that's specific and actionable as we expect.
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 like the latest text wrt the new trigger controller setting metadata that is then interpreted by the existing build controller, which then sets the first class fields in the status of the build run
The more I think about it, the more I am inclined that annotations and not labels should be set by the trigger controller to convey trigger cause, given the label length restrictions and the fact that we are "affecting" the existing controller's behavior and processing of the build run (in which status fields it sets), where k8s conventions say you should annotations for that.
Also, I would not think the existing build related controllers need to do queries based on any trigger labels, right?
But as I said before, I'm also fine with carrying the annotation vs. label decision as an open question to be sorted out during implementation PR review. If you are not convinced to change from labels to annotations here @otaviof I at least would be good with just adding an open question on this, or if I'm the only vote for annotations and @SaschaSchwarze0 or others are good with labels.
I'm also more inclined to start with annotations vs. first class fields, simply to minimize the API impact. We can always move from annotations to first class fields with relative ease. The other direction is not as easy.
Assuming everyone else is fine with avoiding additional first class fields for this, I say we put to bed the annotation vs. label decision one way or the other and we can resolve this thread.
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.
[...]
The more I think about it, the more I am inclined that annotations and not labels should be set by the trigger controller to convey trigger cause, given the label length restrictions and the fact that we are "affecting" the existing controller's behavior and processing of the build run (in which status fields it sets), where k8s conventions say you should annotations for that. Also, I would not think the existing build related controllers need to do queries based on any trigger labels, right?
That's a good point, Gabe! I'll make sure to update the EP to reflect this.
I'm also more inclined to start with annotations vs. first class fields, simply to minimize the API impact. We can always move from annotations to first class fields with relative ease. The other direction is not as easy.
That's exactly the point, if needed be we can "promote" those fields later on.
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.
Please consider the latest changes.
bf1b4a3
to
033fc66
Compare
033fc66
to
467cea4
Compare
Co-authored-by: Gabe Montero <gmontero@redhat.com>
467cea4
to
b868e99
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.
LGTM @otaviof
I'll let @SaschaSchwarze0 make his final pass and when you two are in sync let him tag for merge, given @adambkaplan did the approve
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.
/lgtm
Shipwright Trigger (EP)
This enhancement proposal describes how to receive external events and trigger Shipwright Builds base on those. The three primary mechanisms described are:
Run
): Integrates Shipwright into Tekton Pipelines via Custom-Tasks, allowing users to call out Shipwright Builds directly from pipelines_Prototype
The proposal on this document is based on the protype project shipwright-trigger, and the API changes on PR #1008.
WebHook Support
The example uses a GitHub repository which upon receiving new commits (push), it triggers a new
BuildRun
using the WebHook interface.Shipwright Build with Push Trigger
Tekton Pipelines Integration
Pipelines
On the Tekton integration demo, the following trigger is added on the
Build
resource:And the following Tekton resources are used, please consider.
Tekton Pipeline
Custom Tasks
For the Custom-Tasks demo, the following
Pipeline
was employed.Tekton Pipeline (Custom-Tasks)