don't update phase for already terminated workflow

This commit is contained in:
rushtehrani
2020-11-11 09:53:13 -08:00
parent 3f70f26da4
commit f7e48a0be7
2 changed files with 3 additions and 4 deletions

View File

@@ -905,7 +905,7 @@ func (c *Client) createWorkflowExecutionDB(namespace string, workflowExecution *
return return
} }
func (c *Client) FinishWorkflowExecutionStatisticViaExitHandler(namespace, name string, workflowTemplateID int64, phase wfv1.NodePhase, startedAt time.Time) (err error) { func (c *Client) FinishWorkflowExecutionStatisticViaExitHandler(namespace, name string, phase wfv1.NodePhase, startedAt time.Time) (err error) {
_, err = sb.Update("workflow_executions"). _, err = sb.Update("workflow_executions").
SetMap(sq.Eq{ SetMap(sq.Eq{
"started_at": startedAt.UTC(), "started_at": startedAt.UTC(),
@@ -914,7 +914,7 @@ func (c *Client) FinishWorkflowExecutionStatisticViaExitHandler(namespace, name
"finished_at": time.Now().UTC(), "finished_at": time.Now().UTC(),
"phase": phase, "phase": phase,
}). }).
Where(sq.Eq{"name": name}). Where(sq.Eq{"name": name}, sq.NotEq{"phase": "Terminated"}).
RunWith(c.DB). RunWith(c.DB).
Exec() Exec()

View File

@@ -143,8 +143,7 @@ func (s *WorkflowServer) AddWorkflowExecutionStatistics(ctx context.Context, req
return &empty.Empty{}, err return &empty.Empty{}, err
} }
err = client.FinishWorkflowExecutionStatisticViaExitHandler(req.Namespace, req.Uid, err = client.FinishWorkflowExecutionStatisticViaExitHandler(req.Namespace, req.Uid, phase, workflow.Status.StartedAt.UTC())
req.Statistics.WorkflowTemplateId, phase, workflow.Status.StartedAt.UTC())
if err != nil { if err != nil {
return &empty.Empty{}, err return &empty.Empty{}, err