Skip to content

Commit

Permalink
fix run_task_background getting stuck in running state when foregro…
Browse files Browse the repository at this point in the history
…und task completes
  • Loading branch information
pk910 committed Jan 18, 2024
1 parent cd1cfe4 commit 460b48d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/coordinator/names/validatornames.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (vn *ValidatorNames) LoadValidatorNames() {

vn.names = make(map[uint64]string)

if vn.config == nil {
return
}

// load names
if vn.config.InventoryYaml != "" {
err := vn.loadFromYaml(vn.config.InventoryYaml)
Expand Down
8 changes: 4 additions & 4 deletions pkg/coordinator/tasks/run_task_background/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (t *Task) Execute(ctx context.Context) error {

result := <-t.resultChan
t.ctx.SetResult(result.result)

t.resultChanMtx.Lock()
t.resultChan = nil
t.resultChanMtx.Unlock()
cancel()

<-t.foregroundChan
Expand Down Expand Up @@ -197,10 +201,6 @@ func (t *Task) execForegroundTask(ctx context.Context) {
t.watchTaskResult(ctx, cancelFn)
})

if ctx.Err() != nil {
return
}

taskResult := t.ctx.Scheduler.GetTaskStatus(t.foregroundTask)

taskStatus := "success"
Expand Down

0 comments on commit 460b48d

Please sign in to comment.