Skip to content

Commit

Permalink
fix: Surface underlying error when getting a workflow (#11674)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan committed Aug 26, 2023
1 parent ba523bf commit ac9e2de
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions server/workflow/workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,17 @@ func (s *workflowServer) getWorkflow(ctx context.Context, wfClient versioned.Int
log.Debugf("Resolved alias %s to workflow %s.\n", latestAlias, latest.Name)
return latest, nil
}
wf, err := wfClient.ArgoprojV1alpha1().Workflows(namespace).Get(ctx, name, options)
if wf == nil || err != nil {
var err error
wf, origErr := wfClient.ArgoprojV1alpha1().Workflows(namespace).Get(ctx, name, options)
if wf == nil || origErr != nil {
wf, err = s.wfArchiveServer.GetArchivedWorkflow(ctx, &workflowarchivepkg.GetArchivedWorkflowRequest{
Namespace: namespace,
Name: name,
})
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
log.Errorf("failed to get live workflow: %v; failed to get archived workflow: %v", origErr, err)
// We only return the original error to preserve the original status code.
return nil, sutils.ToStatusError(origErr, codes.Internal)
}
}
return wf, nil
Expand Down

0 comments on commit ac9e2de

Please sign in to comment.