Skip to content

Commit

Permalink
fix: Set initial progress from pod metadata if exists. Fixes #13057
Browse files Browse the repository at this point in the history
Signed-off-by: oninowang <[email protected]>
  • Loading branch information
jswxstw committed Aug 11, 2024
1 parent 16f0a8e commit cd51f5d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
28 changes: 13 additions & 15 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1429,16 +1429,21 @@ func (woc *wfOperationCtx) assessNodeStatus(pod *apiv1.Pod, old *wfv1.NodeStatus
} else {
woc.wf.Status.MarkTaskResultIncomplete(resultName)
}
}

if x, ok := pod.Annotations[common.AnnotationKeyOutputs]; ok {
woc.log.Warn("workflow uses legacy/insecure pod patch, see https://argo-workflows.readthedocs.io/en/latest/workflow-rbac/")
if new.Outputs == nil {
new.Outputs = &wfv1.Outputs{}
if x, ok = pod.Annotations[common.AnnotationKeyOutputs]; ok {
if new.Outputs == nil {
new.Outputs = &wfv1.Outputs{}
}
if err := json.Unmarshal([]byte(x), new.Outputs); err != nil {
new.Phase = wfv1.NodeError
new.Message = err.Error()
}
}
if err := json.Unmarshal([]byte(x), new.Outputs); err != nil {
new.Phase = wfv1.NodeError
new.Message = err.Error()

if x, ok = pod.Annotations[common.AnnotationKeyProgress]; ok {
if p, ok := wfv1.ParseProgress(x); ok {
new.Progress = p
}
}
}

Expand All @@ -1448,13 +1453,6 @@ func (woc *wfOperationCtx) assessNodeStatus(pod *apiv1.Pod, old *wfv1.NodeStatus
new.Progress = wfv1.ProgressDefault
}

if x, ok := pod.Annotations[common.AnnotationKeyProgress]; ok {
woc.log.Warn("workflow uses legacy/insecure pod patch, see https://argo-workflows.readthedocs.io/en/latest/workflow-rbac/")
if p, ok := wfv1.ParseProgress(x); ok {
new.Progress = p
}
}

// We capture the exit-code after we look for the task-result.
// All other outputs are set by the executor, only the exit-code is set by the controller.
// By waiting, we avoid breaking the race-condition check.
Expand Down
12 changes: 12 additions & 0 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ func (woc *wfOperationCtx) createWorkflowPod(ctx context.Context, nodeName strin
woc.addSchedulingConstraints(pod, wfSpec, tmpl, nodeName)
woc.addMetadata(pod, tmpl)

// Set initial progress from pod metadata if exists.
if x, ok := pod.ObjectMeta.Annotations[common.AnnotationKeyProgress]; ok {
if p, ok := wfv1.ParseProgress(x); ok {
node, err := woc.wf.Status.Nodes.Get(nodeID)
if err != nil {
woc.log.Panicf("was unable to obtain node for %s", nodeID)
}
node.Progress = p
woc.wf.Status.Nodes.Set(nodeID, *node)
}
}

err = addVolumeReferences(pod, woc.volumes, tmpl, woc.wf.Status.PersistentVolumeClaims)
if err != nil {
return nil, err
Expand Down

0 comments on commit cd51f5d

Please sign in to comment.