Skip to content

Commit

Permalink
fix(api): resync workflow run status when stopping a job (#5275)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored Jun 23, 2020
1 parent 2cf5f7b commit c51b3b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion engine/api/workflow/resync_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ func ResyncWorkflowRunStatus(ctx context.Context, db gorp.SqlExecutor, wr *sdk.W
newStatus = getRunStatus(counterStatus)
}

log.Debug("ResyncWorkflowRunStatus> %s/%s %+v", newStatus, wr.Status, counterStatus)

if newStatus != wr.Status {
wr.Status = newStatus
report.Add(ctx, *wr)

return report, UpdateWorkflowRunStatus(db, wr)
}

Expand Down
8 changes: 8 additions & 0 deletions engine/api/workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,20 @@ func (api *API) stopWorkflowNodeRunHandler() service.Handler {
return sdk.WrapError(err, "unable to stop workflow node run")
}

// Reload workflow run then resync its status
tx, err := api.mustDB().Begin()
if err != nil {
return sdk.WithStack(err)
}
defer tx.Rollback() // nolint

workflowRun, err = workflow.LoadRun(ctx, tx, p.Key, workflowName, workflowRunNumber, workflow.LoadRunOptions{
WithDeleted: true,
})
if err != nil {
return sdk.WrapError(err, "unable to load workflow run with number %d for workflow %s", workflowRunNumber, workflowName)
}

r1, err := workflow.ResyncWorkflowRunStatus(ctx, tx, workflowRun)
report.Merge(ctx, r1)
if err != nil {
Expand Down

0 comments on commit c51b3b3

Please sign in to comment.