feat: implement 'on error retry' policy (#428)

This commit is contained in:
Gareth
2024-08-26 19:21:18 -07:00
committed by GitHub
parent 8c1cf791bb
commit 038bc87070
16 changed files with 654 additions and 111 deletions

View File

@@ -110,8 +110,14 @@ func (t *taskRunnerImpl) ExecuteHooks(ctx context.Context, events []v1.Hook_Cond
}
if err := t.orchestrator.RunTask(ctx, st); hook.IsHaltingError(err) {
var cancelErr *hook.HookErrorRequestCancel
var retryErr *hook.HookErrorRetry
if errors.As(err, &cancelErr) {
return fmt.Errorf("%w: %w", tasks.ErrTaskCancelled, err)
return fmt.Errorf("%v: %w: %w", task.Name(), &tasks.TaskCancelledError{}, cancelErr.Err)
} else if errors.As(err, &retryErr) {
return fmt.Errorf("%v: %w", task.Name(), &tasks.TaskRetryError{
Err: retryErr.Err,
Backoff: retryErr.Backoff,
})
}
return fmt.Errorf("%v: %w", task.Name(), err)
}