Skip to content

Commit 7df4798

Browse files
committed
code cleanup
1 parent 1076662 commit 7df4798

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

prunner.go

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ func (r *PipelineRunner) RunJobErrorHandler(job *PipelineJob) {
448448
}
449449
}
450450

451+
const OnErrorTaskName = "on_error"
452+
451453
func (r *PipelineRunner) buildErrorGraph(job *PipelineJob) (*scheduler.ExecutionGraph, error) {
452454
r.mx.RLock()
453455
defer r.mx.RUnlock()
@@ -576,7 +578,24 @@ func (r *PipelineRunner) HandleTaskChange(t *task.Task) {
576578
if jt == nil {
577579
return
578580
}
579-
updateJobTaskStateFromTask(jt, t)
581+
if !t.Start.IsZero() {
582+
start := t.Start
583+
jt.Start = &start
584+
}
585+
if !t.End.IsZero() {
586+
end := t.End
587+
jt.End = &end
588+
}
589+
jt.ExitCode = t.ExitCode
590+
jt.Skipped = t.Skipped
591+
592+
// Set canceled flag on the job if a task was canceled through the context
593+
if errors.Is(t.Error, context.Canceled) {
594+
jt.Canceled = true
595+
} else {
596+
jt.Errored = t.Errored
597+
jt.Error = t.Error
598+
}
580599

581600
// If the task has errored, and we want to fail-fast (ContinueRunningTasksAfterFailure is false),
582601
// then we directly abort all other tasks of the job.
@@ -599,33 +618,6 @@ func (r *PipelineRunner) HandleTaskChange(t *task.Task) {
599618
r.requestPersist()
600619
}
601620

602-
// updateJobTaskStateFromTask updates jobTask properties from a given taskCtl task.Task.
603-
// Very internal helper function, to be used in PipelineRunner.HandleTaskChange
604-
// and PipelineRunner.runOnErrorScript.
605-
func updateJobTaskStateFromTask(jt *jobTask, t *task.Task) {
606-
if !t.Start.IsZero() {
607-
start := t.Start
608-
jt.Start = &start
609-
}
610-
if !t.End.IsZero() {
611-
end := t.End
612-
jt.End = &end
613-
}
614-
jt.ExitCode = t.ExitCode
615-
jt.Skipped = t.Skipped
616-
617-
// Set canceled flag on the job if a task was canceled through the context
618-
if errors.Is(t.Error, context.Canceled) {
619-
jt.Canceled = true
620-
} else {
621-
jt.Errored = t.Errored
622-
jt.Error = t.Error
623-
}
624-
625-
}
626-
627-
const OnErrorTaskName = "on_error"
628-
629621
// HandleStageChange will be called when the stage state changes in the scheduler
630622
func (r *PipelineRunner) HandleStageChange(stage *scheduler.Stage) {
631623
r.mx.Lock()

0 commit comments

Comments
 (0)