Skip to content

Commit

Permalink
cloudevent: make sure we enter the channel before…
Browse files Browse the repository at this point in the history
… returning. This effectively wait for the goroutine to be schedule
before getting out of `SendCloudEventWithRetries`. That way we are
sure the "sending cloud event" goroutine is scheduled. This doesn't
wait for `ceClient.Send` to execute, just making sure we got in the
goroutine.

This should fix flaky tests observed during release pipeline runs.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Jul 3, 2020
1 parent bbb767c commit 4bdeaa3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/reconciler/events/cloudevent/cloud_event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error
return err
}

wasIn := make(chan error)
go func() {
wasIn <- nil
if result := ceClient.Send(cloudevents.ContextWithRetriesExponentialBackoff(ctx, 10*time.Millisecond, 10), *event); !cloudevents.IsACK(result) {
logger.Warnf("Failed to send cloudevent: %s", result.Error())
recorder := controller.GetEventRecorder(ctx)
Expand All @@ -148,5 +150,5 @@ func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error
}
}()

return nil
return <-wasIn
}

0 comments on commit 4bdeaa3

Please sign in to comment.