@@ -444,12 +444,14 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDWorkflowStatusUpdate() error
444
444
impl .logger .Error ("err" , err )
445
445
return
446
446
}
447
+
447
448
if stateChanged {
448
449
wfr , err := impl .cdWorkflowRepository .FindWorkflowRunnerById (wfrId )
449
450
if err != nil {
450
451
impl .logger .Errorw ("could not get wf runner" , "wfrId" , wfrId , "err" , err )
451
452
return
452
453
}
454
+
453
455
if wfrStatus == string (v1alpha1 .NodeFailed ) || wfrStatus == string (v1alpha1 .NodeError ) {
454
456
if len (wfr .ImagePathReservationIds ) > 0 {
455
457
err := impl .cdHandler .DeactivateImageReservationPathsOnFailure (wfr .ImagePathReservationIds )
@@ -458,22 +460,28 @@ func (impl *WorkflowEventProcessorImpl) SubscribeCDWorkflowStatusUpdate() error
458
460
}
459
461
}
460
462
}
461
- if wfrStatus == string (v1alpha1 .NodeSucceeded ) || wfrStatus == string (v1alpha1 .NodeFailed ) || wfrStatus == string (v1alpha1 .NodeError ) {
462
- eventType := eventUtil .EventType (0 )
463
- if wfrStatus == string (v1alpha1 .NodeSucceeded ) {
464
- eventType = eventUtil .Success
465
- } else if wfrStatus == string (v1alpha1 .NodeFailed ) || wfrStatus == string (v1alpha1 .NodeError ) {
466
- eventType = eventUtil .Fail
467
- }
468
463
464
+ wfStatusInEvent := string (wfStatus .Phase )
465
+ if wfStatusInEvent == string (v1alpha1 .NodeSucceeded ) || wfStatusInEvent == string (v1alpha1 .NodeFailed ) || wfStatusInEvent == string (v1alpha1 .NodeError ) {
466
+ // the re-trigger should only happen when we get a pod deleted event.
469
467
if wfr != nil && executors .CheckIfReTriggerRequired (wfrStatus , wfStatus .Message , wfr .Status ) {
470
468
err = impl .workflowDagExecutor .HandleCdStageReTrigger (wfr )
471
469
if err != nil {
472
- //check if this log required or not
470
+ // check if this log required or not
473
471
impl .logger .Errorw ("error in HandleCdStageReTrigger" , "workflowRunnerId" , wfr .Id , "workflowStatus" , wfrStatus , "workflowStatusMessage" , wfStatus .Message , "error" , err )
474
472
}
475
473
impl .logger .Debugw ("re-triggered cd stage" , "workflowRunnerId" , wfr .Id , "workflowStatus" , wfrStatus , "workflowStatusMessage" , wfStatus .Message )
476
474
} else {
475
+ // we send this notification on *workflow_runner* status, both success and failure
476
+ // during workflow runner failure, particularly when failure occurred due to pod deletion , we get two events from kubewatch.
477
+ // event1: with failure status + exit-code [need to send notification]
478
+ // event2: with failure status + pod deletion message [skip notification]
479
+ eventType := eventUtil .EventType (0 )
480
+ if wfStatusInEvent == string (v1alpha1 .NodeSucceeded ) {
481
+ eventType = eventUtil .Success
482
+ } else if wfStatusInEvent == string (v1alpha1 .NodeFailed ) || wfStatusInEvent == string (v1alpha1 .NodeError ) {
483
+ eventType = eventUtil .Fail
484
+ }
477
485
impl .sendPrePostCdNotificationEvent (eventType , wfr )
478
486
}
479
487
}
0 commit comments