Skip to content

Commit

Permalink
fix(controller): Enhance output capture (#5450)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec authored Mar 20, 2021
1 parent 46aaa70 commit 9a1c046
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,21 +1158,21 @@ func (woc *wfOperationCtx) assessNodeStatus(pod *apiv1.Pod, node *wfv1.NodeStatu
}
}
}
// outputs are mixed between the annotation (parameters, artifacts, and result) and the pod's status (exit code)
if exitCode := getExitCode(pod); exitCode != nil {
if node.Outputs == nil {
node.Outputs = &wfv1.Outputs{}
}
woc.log.Infof("Updating node %s exit code %v -> %v", node.ID, node.Outputs.ExitCode, *exitCode)
if outputStr, ok := pod.Annotations[common.AnnotationKeyOutputs]; ok {
woc.log.Infof("Setting node %v outputs: %s", node.ID, outputStr)
if err := json.Unmarshal([]byte(outputStr), node.Outputs); err != nil { // I don't expect an error to ever happen in production
node.Phase = wfv1.NodeError
node.Message = err.Error()

// we only need to update these values if the container transitions to complete
if !node.Phase.Fulfilled() && newPhase.Fulfilled() {
// outputs are mixed between the annotation (parameters, artifacts, and result) and the pod's status (exit code)
if exitCode := getExitCode(pod); exitCode != nil {
woc.log.Infof("Updating node %s exit code %d", node.ID, *exitCode)
node.Outputs = &wfv1.Outputs{ExitCode: pointer.StringPtr(fmt.Sprintf("%d", int(*exitCode)))}
if outputStr, ok := pod.Annotations[common.AnnotationKeyOutputs]; ok {
woc.log.Infof("Setting node %v outputs: %s", node.ID, outputStr)
if err := json.Unmarshal([]byte(outputStr), node.Outputs); err != nil { // I don't expect an error to ever happen in production
node.Phase = wfv1.NodeError
node.Message = err.Error()
}
}
}
node.Outputs.ExitCode = pointer.StringPtr(fmt.Sprintf("%d", int(*exitCode)))
updated = true
}

if node.Phase != newPhase {
Expand Down

0 comments on commit 9a1c046

Please sign in to comment.