feat(taskactions): retry a parked task on the current workflow definition
This commit is contained in:
1 parent
c80d4750a8
commit
9d7287c647
18 files changed
+134
-58
No files matched your search
@@ -890,17 +890,21 @@ UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
workflow = CASE WHEN $1::text = '' THEN workflow ELSE $1::text END,
|
||||
retry_mode = $2::text,
|
||||
resume_from = $3::text, resume_results = $4::jsonb,
|
||||
workflow_definition_yaml = CASE WHEN $5::bool THEN '' ELSE workflow_definition_yaml END,
|
||||
workflow_definition_digest = CASE WHEN $5::bool THEN '' ELSE workflow_definition_digest END,
|
||||
workflow_definition_version = CASE WHEN $5::bool THEN 0 ELSE workflow_definition_version END,
|
||||
park_reason = '', park_class = 'needs_human', updated_at = now()
|
||||
WHERE id = $5 AND status = $6
|
||||
WHERE id = $6 AND status = $7
|
||||
`
|
||||
|
||||
type RetryTaskParams struct {
|
||||
Workflow string
|
||||
RetryMode string
|
||||
ResumeFrom string
|
||||
ResumeResults []byte
|
||||
ID int64
|
||||
FromStatus string
|
||||
Workflow string
|
||||
RetryMode string
|
||||
ResumeFrom string
|
||||
ResumeResults []byte
|
||||
CurrentDefinition bool
|
||||
ID int64
|
||||
FromStatus string
|
||||
}
|
||||
|
||||
func (q *Queries) RetryTask(ctx context.Context, arg RetryTaskParams) (int64, error) {
|
||||
@@ -909,6 +913,7 @@ func (q *Queries) RetryTask(ctx context.Context, arg RetryTaskParams) (int64, er
|
||||
arg.RetryMode,
|
||||
arg.ResumeFrom,
|
||||
arg.ResumeResults,
|
||||
arg.CurrentDefinition,
|
||||
arg.ID,
|
||||
arg.FromStatus,
|
||||
)
|
||||
|
||||
@@ -258,6 +258,9 @@ UPDATE tasks SET status = 'queued', retry_count = retry_count + 1,
|
||||
workflow = CASE WHEN @workflow::text = '' THEN workflow ELSE @workflow::text END,
|
||||
retry_mode = @retry_mode::text,
|
||||
resume_from = @resume_from::text, resume_results = @resume_results::jsonb,
|
||||
workflow_definition_yaml = CASE WHEN @current_definition::bool THEN '' ELSE workflow_definition_yaml END,
|
||||
workflow_definition_digest = CASE WHEN @current_definition::bool THEN '' ELSE workflow_definition_digest END,
|
||||
workflow_definition_version = CASE WHEN @current_definition::bool THEN 0 ELSE workflow_definition_version END,
|
||||
park_reason = '', park_class = 'needs_human', updated_at = now()
|
||||
WHERE id = @id AND status = @from_status;
|
||||
|
||||
|
||||
@@ -535,9 +535,11 @@ func (s *Store) Requeue(ctx context.Context, taskID int64, fromStatus, wf string
|
||||
// transaction, under the same table check Requeue applies. retryMode is the
|
||||
// operator's worktree choice for the next dispatch; the store persists it
|
||||
// unread so the daemon's prepareWorkspace reads the mode the operator set.
|
||||
// currentDefinition clears the pinned definition so the next dispatch pins
|
||||
// the workflow's current stored version.
|
||||
// A resume copies the results recorded after its After stage onto the row, in
|
||||
// the same transaction, so the attempt starts from what that stage left.
|
||||
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume) error {
|
||||
func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, retryMode string, resume task.Resume, currentDefinition bool) error {
|
||||
return s.requeue(ctx, taskID, fromStatus, wf, "retried "+wf, func(q *postgresdb.Queries) (int64, error) {
|
||||
results, err := resumeResults(ctx, q, taskID, resume)
|
||||
if err != nil {
|
||||
@@ -545,7 +547,7 @@ func (s *Store) RetryTask(ctx context.Context, taskID int64, fromStatus, wf, ret
|
||||
}
|
||||
return q.RetryTask(ctx, postgresdb.RetryTaskParams{
|
||||
ID: taskID, Workflow: wf, FromStatus: fromStatus, RetryMode: retryMode,
|
||||
ResumeFrom: resume.From, ResumeResults: results,
|
||||
ResumeFrom: resume.From, ResumeResults: results, CurrentDefinition: currentDefinition,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user