Skip to content

Commit 291801a

Browse files
committed
workflow: broaden logic to capture session cancellation
1 parent 9f0a064 commit 291801a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/workflow/processing.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package workflow
88
import (
99
"errors"
1010
"fmt"
11+
"strings"
1112
"time"
1213

1314
"github.com/artefactual-labs/enduro/internal/collection"
@@ -209,12 +210,11 @@ func (w *ProcessingWorkflow) Execute(ctx workflow.Context, req *collection.Proce
209210

210211
sessErr = w.SessionHandler(sessCtx, attempt, tinfo, nameInfo)
211212

212-
// When we want to start over again. Possible scenarios:
213-
//
214-
// A) Worker died (ErrSessionFailed) or wants to quit (ErrCanceled).
215-
// B) Workflow is canceled (ErrCanceled).
216-
//
217-
if errors.Is(sessErr, workflow.ErrSessionFailed) || errors.Is(sessErr, workflow.ErrCanceled) {
213+
// We want to retry the session if it has been canceled as a result
214+
// of losing the worker but not otherwise. This scenario seems to be
215+
// identifiable when we have an error but the root context has not
216+
// been canceled.
217+
if sessErr != nil && (errors.Is(sessErr, workflow.ErrSessionFailed) || errors.Is(sessErr, workflow.ErrCanceled) || strings.Contains(sessErr.Error(), "CanceledError")) {
218218
// Root context canceled, hence workflow canceled.
219219
if ctx.Err() == workflow.ErrCanceled {
220220
return nil

0 commit comments

Comments
 (0)