Skip to content

Commit a71ba16

Browse files
authored
feat(pipelineloop): Update pipelineloop v2 to have failed and cancelled status (#1445)
* update pipelineloop v2 to have failed and cancelled status * fix execution id update bug
1 parent ff8bb50 commit a71ba16

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun/pipelinelooprun.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,36 @@ func (c *Reconciler) reconcile(ctx context.Context, customRun *tektonv1beta1.Cus
433433
}
434434
// CustomRun is cancelled, just cancel all the running instance and return
435435
if customRun.IsCancelled() {
436+
var DAGStatus pb.Execution_State
436437
if len(failedPrs) > 0 {
437438
customRun.Status.MarkCustomRunFailed(pipelineloopv1alpha1.PipelineLoopRunReasonFailed.String(),
438439
"CustomRun %s/%s was failed",
439440
customRun.Namespace, customRun.Name)
441+
DAGStatus = pb.Execution_FAILED
440442
} else {
441443
reason := pipelineloopv1alpha1.PipelineLoopRunReasonCancelled.String()
442444
if customRun.HasTimedOut(c.clock) { // This check is only possible if we are on tekton 0.27.0 +
443445
reason = string(tektonv1beta1.CustomRunReasonTimedOut)
444446
}
445447
customRun.Status.MarkCustomRunFailed(reason, "CustomRun %s/%s was cancelled", customRun.Namespace, customRun.Name)
448+
DAGStatus = pb.Execution_CANCELED
449+
}
450+
if c.runKFPV2Driver == "true" {
451+
options, err := kfptask.ParseParams(customRun)
452+
if err != nil {
453+
logger.Errorf("Run %s/%s is invalid because of %s", customRun.Namespace, customRun.Name, err)
454+
customRun.Status.MarkCustomRunFailed(kfptask.ReasonFailedValidation,
455+
"Run can't be run because it has an invalid param - %v", err)
456+
return err
457+
}
458+
DAGErr := kfptask.UpdateDAGPublisher(ctx, options, DAGStatus)
459+
if err != nil {
460+
logger.Errorf("kfp publisher failed when reconciling Run %s/%s: %v", customRun.Namespace, customRun.Name, DAGErr)
461+
customRun.Status.MarkCustomRunFailed(kfptask.ReasonDriverError,
462+
"kfp publisher execution failed: %v", DAGErr)
463+
return DAGErr
464+
}
446465
}
447-
448466
for _, currentRunningPr := range currentRunningPrs {
449467
logger.Infof("CustomRun %s/%s is cancelled. Cancelling PipelineRun %s.", customRun.Namespace, customRun.Name, currentRunningPr.Name)
450468
if _, err := c.pipelineClientSet.TektonV1().PipelineRuns(customRun.Namespace).Patch(ctx, currentRunningPr.Name, types.JSONPatchType, cancelPatchBytes, metav1.PatchOptions{}); err != nil {

0 commit comments

Comments
 (0)