Skip to content

Commit f00dd88

Browse files
committed
Emit events from the PipelineRun controller
Emit events: - Pipeline Start - Pipeline Started Running - Various Error Conditions, Cancel, Timeout Emit all events through the events.go module. Align and simplify the reconcile structure to have clear points for error handling and emitting events. Added test for the normal reconcile to copmletion case. Added more event checks to existing tests.
1 parent 6ae926f commit f00dd88

File tree

6 files changed

+778
-338
lines changed

6 files changed

+778
-338
lines changed

pkg/apis/pipeline/v1beta1/pipelinerun_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ func (pr *PipelineRunStatus) MarkResourceNotConvertible(err *CannotConvertError)
239239
})
240240
}
241241

242+
// MarkResourceFailed sets the ConditionSucceeded condition to ConditionFalse
243+
// based on an error that occurred and a reason
244+
func (pr *PipelineRunStatus) MarkResourceFailed(reason string, err error) {
245+
pipelineRunCondSet.Manage(pr).SetCondition(apis.Condition{
246+
Type: apis.ConditionSucceeded,
247+
Status: corev1.ConditionFalse,
248+
Reason: reason,
249+
Message: err.Error(),
250+
})
251+
}
252+
242253
// PipelineRunStatusFields holds the fields of PipelineRunStatus' status.
243254
// This is defined separately and inlined so that other types can readily
244255
// consume these fields via duck typing.

pkg/reconciler/pipelinerun/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func NewController(images pipeline.Images) func(context.Context, configmap.Watch
6969
ConfigMapWatcher: cmw,
7070
ResyncPeriod: resyncPeriod,
7171
Logger: logger,
72+
Recorder: controller.GetEventRecorder(ctx),
7273
}
7374

7475
c := &Reconciler{

0 commit comments

Comments
 (0)