-
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
Emit events when we fail to update the taskrun #2526
Emit events when we fail to update the taskrun #2526
Conversation
The following is the coverage report on the affected files.
|
a468b43
to
1f411f8
Compare
The following is the coverage report on the affected files.
|
Emit additional events: - Pipeline Start Emit all events through the events.go module. Align and simplify the reconcile structure to have clear points for error handling and emitting events. Depends on tektoncd#2543 Depends on tektoncd#2526
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.
/meow
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: vdemeester 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 |
|
||
// EmitErrorEvent emits a failure associated to an error | ||
func EmitErrorEvent(c record.EventRecorder, err error, object runtime.Object) { | ||
if err != nil { |
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.
feels a bit odd to have this function take an error as an argument vs checking the error in the place where it originates - is this a pattern we do other places as well?
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.
Well, it's a bit different because in this case the error is the event that we want to send.
On knative they went a bit further, they have now an event object that also implements the error interface.
They have a generated Reconcile
that invokes a ReconcileKind
which returns an event that may be an error - at least that's how I understood it - so this goes a bit in that direction.
I could check if the err
is nil at the source, but it felt safer to do 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.
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.
My plan for upcoming patches was to centralize the event logic in event.go
i.e. to receive all requests events / error notifications from the taskrun/pipelinerun controller in there, and to decide there when to emit what, k8s event and/or cloudevent.
|
||
err := checkEvents(fr, ts.name, ts.wantEvent) | ||
if err != nil { | ||
t.Errorf(err.Error()) |
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.
might be nice to add some context, e.g. "expected error when blah blah"
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 context is added in the error by checkEvents
already.
I could add unexpected error when checking for events: %#v", err.Error()
but I'm not sure it would add much.
afterCondition := tr.Status.GetCondition(apis.ConditionSucceeded) | ||
reconciler.EmitEvent(c.Recorder, beforeCondition, afterCondition, tr) | ||
err := c.updateStatusLabelsAndAnnotations(tr, original) | ||
reconciler.EmitErrorEvent(c.Recorder, err, tr) |
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.
personally i think id rather see an explicit "if err" here vs having EmitErrorEvent handle it, just cuz it doesnt seem consistent with how we usually do error handling - maybe you have a bigger plan around this tho that im not seeing
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 discovered https://github.com/knative/pkg/tree/master/injection#generated-reconciler-responsibilities after I wrote this patch. Maybe I should just try and adopt that :P
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 trying to centralize the logic about what event to send when of what type in events.go, so I included there the check for nil too
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 havent seen https://github.com/knative/pkg/tree/master/injection#generated-reconciler-responsibilities before! Glancing at it I'm not 100% sure what implications it has for this PR, im really glad to see some docs for pkg tho.
I'm trying to centralize the logic about what event to send when of what type in events.go, so I included there the check for nil too
okay, maybe it will make more sense to me as it evolves
Emit additional events: - Pipeline Start Emit all events through the events.go module. Align and simplify the reconcile structure to have clear points for error handling and emitting events. Depends on tektoncd#2543 Depends on tektoncd#2526
Emit additional events: - Pipeline Start Emit all events through the events.go module. Align and simplify the reconcile structure to have clear points for error handling and emitting events. Depends on tektoncd#2543 Depends on tektoncd#2526
This PR cannot be merged: expecting exactly one kind/ label Available
|
1 similar comment
This PR cannot be merged: expecting exactly one kind/ label Available
|
This PR cannot be merged: expecting exactly one kind/ label Available
|
/lgtm |
/kind feature |
Similarly to how the pipeline controller does, we should emit events when we fail to update the taskrun. Events on reconcile error use a dedicated reason.
1f411f8
to
a8d40e2
Compare
@bobcatfish I had to rebase because of the stored v1beta1 version :) |
The following is the coverage report on the affected files.
|
/test pull-tekton-pipeline-integration-tests |
/lgtm |
Emit additional events: - Pipeline Start Emit all events through the events.go module. Align and simplify the reconcile structure to have clear points for error handling and emitting events. Depends on tektoncd#2543 Depends on tektoncd#2526
Changes
Similarly to how the pipeline controller does, we should emit events
when we fail to update the taskrun.
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.
Double check this list of stuff that's easy to miss:
cmd
dir, please updatethe release Task to build and release this image.
Reviewer Notes
If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.
Release Notes