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
|
var groupWait sync.WaitGroup
|
||||||
|
|
||||||
for _, job := range group {
|
for _, job := range group {
|
||||||
groupWait.Add(1)
|
|
||||||
|
|
||||||
jobTracker := NewTaskTracker(rootTracker)
|
jobTracker := NewTaskTracker(rootTracker)
|
||||||
runnerImage, defined := r.Labels[job.RunsOn]
|
runnerImage, defined := r.Labels[job.RunsOn]
|
||||||
if !defined {
|
if !defined {
|
||||||
|
@ -54,6 +52,7 @@ func (r *Runner) RunWorkflow(workflow workflow.Workflow) TaskTracker {
|
||||||
jobContext := context.WithValue(workflowContext, "currentJob", job)
|
jobContext := context.WithValue(workflowContext, "currentJob", job)
|
||||||
jobContext = context.WithValue(jobContext, "runnerImageUri", runnerImage)
|
jobContext = context.WithValue(jobContext, "runnerImageUri", runnerImage)
|
||||||
|
|
||||||
|
groupWait.Add(1)
|
||||||
go r.runJob(jobContext, jobTracker, &groupWait)
|
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) {
|
func (r Runner) runJob(jobContext context.Context, jobTracker *TaskTracker, jobWaitGroup *sync.WaitGroup) {
|
||||||
job := jobContext.Value("currentJob").(workflow.Job)
|
job := jobContext.Value("currentJob").(workflow.Job)
|
||||||
containerName := fmt.Sprintf("runner-%s", jobTracker.TaskId)
|
containerName := fmt.Sprintf("runner-%s", jobTracker.TaskId)
|
||||||
defer r.deferred.RunDeferredTasksInScope(fmt.Sprintf("job-%s", containerName))
|
|
||||||
defer jobWaitGroup.Done()
|
defer jobWaitGroup.Done()
|
||||||
|
defer r.deferred.RunDeferredTasksInScope(fmt.Sprintf("job-%s", containerName))
|
||||||
|
|
||||||
jobTracker.SetStatus("started")
|
jobTracker.SetStatus("started")
|
||||||
runnerImage := jobContext.Value("runnerImageUri").(string)
|
runnerImage := jobContext.Value("runnerImageUri").(string)
|
||||||
|
|
Loading…
Reference in a new issue