Skip to content

Commit

Permalink
fix(executor):Failure node failed to get archived log (argoproj#5671)
Browse files Browse the repository at this point in the history
  • Loading branch information
uucloud committed Apr 13, 2021
1 parent b7d6905 commit d5e492c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
23 changes: 6 additions & 17 deletions cmd/argoexec/commands/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,35 @@ func waitContainer(ctx context.Context) error {
}()

// Wait for main container to complete
waitErr := wfExecutor.Wait(ctx)
if waitErr != nil {
wfExecutor.AddError(waitErr)
// do not return here so we can still try to kill sidecars & save outputs
err := wfExecutor.Wait(ctx)
if err != nil {
wfExecutor.AddError(err)
}

// Capture output script result
err := wfExecutor.CaptureScriptResult(ctx)
err = wfExecutor.CaptureScriptResult(ctx)
if err != nil {
wfExecutor.AddError(err)
return err
}
// Saving logs
logArt, err := wfExecutor.SaveLogs(ctx)
if err != nil {
wfExecutor.AddError(err)
return err
}
// Saving output parameters
err = wfExecutor.SaveParameters(ctx)
if err != nil {
wfExecutor.AddError(err)
return err
}
// Saving output artifacts
err = wfExecutor.SaveArtifacts(ctx)
if err != nil {
wfExecutor.AddError(err)
return err
}
// Annotating pod with output
err = wfExecutor.AnnotateOutputs(ctx, logArt)
if err != nil {
wfExecutor.AddError(err)
return err
}

// To prevent the workflow step from completing successfully, return the error occurred during wait.
if waitErr != nil {
return waitErr
}

return nil
return wfExecutor.HasError()
}
10 changes: 9 additions & 1 deletion workflow/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,12 +728,20 @@ func (we *WorkflowExecutor) AnnotateOutputs(ctx context.Context, logArt *wfv1.Ar
return we.AddAnnotation(ctx, common.AnnotationKeyOutputs, string(outputBytes))
}

// AddError adds an error to the list of encountered errors durign execution
// AddError adds an error to the list of encountered errors during execution
func (we *WorkflowExecutor) AddError(err error) {
log.Errorf("executor error: %+v", err)
we.errors = append(we.errors, err)
}

// HasError return the first error if exist
func (we *WorkflowExecutor) HasError() error {
if len(we.errors) > 0 {
return we.errors[0]
}
return nil
}

// AddAnnotation adds an annotation to the workflow pod
func (we *WorkflowExecutor) AddAnnotation(ctx context.Context, key, value string) error {
return common.AddPodAnnotation(ctx, we.ClientSet, we.PodName, we.Namespace, key, value, ExecutorRetry)
Expand Down

0 comments on commit d5e492c

Please sign in to comment.