Skip to content

Commit

Permalink
workflow: broaden logic to capture session cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Apr 13, 2020
1 parent 9f0a064 commit 291801a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/workflow/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package workflow
import (
"errors"
"fmt"
"strings"
"time"

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

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

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

0 comments on commit 291801a

Please sign in to comment.