fix: ensure that deferred tasks are run before ending job waitgroups
This commit is contained in:
parent
11c964e7be
commit
e06b46e32d
1 changed files with 3 additions and 3 deletions
|
@ -42,8 +42,6 @@ func (r *Runner) RunWorkflow(workflow workflow.Workflow) TaskTracker {
|
|||
var groupWait sync.WaitGroup
|
||||
|
||||
for _, job := range group {
|
||||
groupWait.Add(1)
|
||||
|
||||
jobTracker := NewTaskTracker(rootTracker)
|
||||
runnerImage, defined := r.Labels[job.RunsOn]
|
||||
if !defined {
|
||||
|
@ -54,6 +52,7 @@ func (r *Runner) RunWorkflow(workflow workflow.Workflow) TaskTracker {
|
|||
jobContext := context.WithValue(workflowContext, "currentJob", job)
|
||||
jobContext = context.WithValue(jobContext, "runnerImageUri", runnerImage)
|
||||
|
||||
groupWait.Add(1)
|
||||
go r.runJob(jobContext, jobTracker, &groupWait)
|
||||
}
|
||||
|
||||
|
@ -69,8 +68,9 @@ func (r *Runner) RunWorkflow(workflow workflow.Workflow) TaskTracker {
|
|||
func (r Runner) runJob(jobContext context.Context, jobTracker *TaskTracker, jobWaitGroup *sync.WaitGroup) {
|
||||
job := jobContext.Value("currentJob").(workflow.Job)
|
||||
containerName := fmt.Sprintf("runner-%s", jobTracker.TaskId)
|
||||
defer r.deferred.RunDeferredTasksInScope(fmt.Sprintf("job-%s", containerName))
|
||||
|
||||
defer jobWaitGroup.Done()
|
||||
defer r.deferred.RunDeferredTasksInScope(fmt.Sprintf("job-%s", containerName))
|
||||
|
||||
jobTracker.SetStatus("started")
|
||||
runnerImage := jobContext.Value("runnerImageUri").(string)
|
||||
|
|
Loading…
Reference in a new issue