Skip to content

Commit

Permalink
fix: use GetTemplateFromNode to determine template name (#12970)
Browse files Browse the repository at this point in the history
Co-authored-by: Anton Gilgur <[email protected]>
Signed-off-by: Ryan Currah <[email protected]>
(cherry picked from commit d578d2c)
  • Loading branch information
ryancurrah authored and agilgur5 committed May 4, 2024
1 parent 574a2d7 commit 27a3159
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cmd/argo/commands/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/argoproj/argo-workflows/v3/pkg/apiclient"
workflowpkg "github.com/argoproj/argo-workflows/v3/pkg/apiclient/workflow"
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
wfutil "github.com/argoproj/argo-workflows/v3/workflow/util"
)

func NewCpCommand() *cobra.Command {
Expand Down Expand Up @@ -82,7 +83,7 @@ func NewCpCommand() *cobra.Command {
if nodeInfo == nil {
return fmt.Errorf("could not get node status for node ID %s", artifact.NodeID)
}
customPath = strings.Replace(customPath, "{templateName}", nodeInfo.TemplateName, 1)
customPath = strings.Replace(customPath, "{templateName}", wfutil.GetTemplateFromNode(*nodeInfo), 1)
customPath = strings.Replace(customPath, "{namespace}", namespace, 1)
customPath = strings.Replace(customPath, "{workflowName}", workflowName, 1)
customPath = strings.Replace(customPath, "{nodeId}", artifact.NodeID, 1)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fixtures/then.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (t *Then) ExpectWorkflowNode(selector func(status wfv1.NodeStatus) bool, f
ObjectMeta: *metadata,
}
version := util.GetWorkflowPodNameVersion(wf)
podName := util.GeneratePodName(t.wf.Name, n.Name, n.TemplateName, n.ID, version)
podName := util.GeneratePodName(t.wf.Name, n.Name, util.GetTemplateFromNode(*n), n.ID, version)

var err error
ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion util/printer/workflow-printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func countPendingRunningCompletedNodes(wf *wfv1.Workflow) (int, int, int) {
running := 0
completed := 0
for _, node := range wf.Status.Nodes {
tmpl := wf.GetTemplateByName(node.TemplateName)
tmpl := wf.GetTemplateByName(util.GetTemplateFromNode(node))
if tmpl == nil || !tmpl.IsPodType() {
continue
}
Expand Down
5 changes: 1 addition & 4 deletions workflow/controller/artifact_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ func (woc *wfOperationCtx) processArtifactGCStrategy(ctx context.Context, strate
woc.log.Errorf("Was unable to obtain node for %s", artifactSearchResult.NodeID)
return fmt.Errorf("can't process Artifact GC Strategy %s: node ID %q not found in Status??", strategy, artifactSearchResult.NodeID)
}
templateName := node.TemplateName
if templateName == "" && node.GetTemplateRef() != nil {
templateName = node.GetTemplateRef().Template
}
templateName := util.GetTemplateFromNode(*node)
if templateName == "" {
return fmt.Errorf("can't process Artifact GC Strategy %s: node %+v has an unnamed template", strategy, node)
}
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/exec_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (woc *wfOperationCtx) killDaemonedChildren(nodeID string) {
if !childNode.IsDaemoned() {
continue
}
podName := util.GeneratePodName(woc.wf.Name, childNode.Name, childNode.TemplateName, childNode.ID, util.GetWorkflowPodNameVersion(woc.wf))
podName := util.GeneratePodName(woc.wf.Name, childNode.Name, util.GetTemplateFromNode(childNode), childNode.ID, util.GetWorkflowPodNameVersion(woc.wf))
woc.controller.queuePodForCleanup(woc.wf.Namespace, podName, terminateContainers)
childNode.Phase = wfv1.NodeSucceeded
childNode.Daemoned = nil
Expand Down
8 changes: 4 additions & 4 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ func (woc *wfOperationCtx) operate(ctx context.Context) {
failedNodeStatus{
DisplayName: node.DisplayName,
Message: node.Message,
TemplateName: node.TemplateName,
TemplateName: wfutil.GetTemplateFromNode(node),
Phase: string(node.Phase),
PodName: wfutil.GeneratePodName(woc.wf.Name, node.Name, node.TemplateName, node.ID, wfutil.GetPodNameVersion()),
PodName: wfutil.GeneratePodName(woc.wf.Name, node.Name, wfutil.GetTemplateFromNode(node), node.ID, wfutil.GetPodNameVersion()),
FinishedAt: node.FinishedAt,
})
}
Expand Down Expand Up @@ -1334,7 +1334,7 @@ func (woc *wfOperationCtx) assessNodeStatus(pod *apiv1.Pod, old *wfv1.NodeStatus
new.Phase = wfv1.NodeSucceeded
} else {
new.Phase, new.Message = woc.inferFailedReason(pod, tmpl)
woc.log.WithField("displayName", old.DisplayName).WithField("templateName", old.TemplateName).
woc.log.WithField("displayName", old.DisplayName).WithField("templateName", wfutil.GetTemplateFromNode(*old)).
WithField("pod", pod.Name).Infof("Pod failed: %s", new.Message)
}
new.Daemoned = nil
Expand Down Expand Up @@ -2624,7 +2624,7 @@ func (woc *wfOperationCtx) getPodByNode(node *wfv1.NodeStatus) (*apiv1.Pod, erro
return nil, fmt.Errorf("Expected node type %s, got %s", wfv1.NodeTypePod, node.Type)
}

podName := woc.getPodName(node.Name, node.TemplateName)
podName := woc.getPodName(node.Name, wfutil.GetTemplateFromNode(*node))
return woc.controller.getPod(woc.wf.GetNamespace(), podName)
}

Expand Down
2 changes: 1 addition & 1 deletion workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func ResumeWorkflow(ctx context.Context, wfIf v1alpha1.WorkflowInterface, hydrat
func SelectorMatchesNode(selector fields.Selector, node wfv1.NodeStatus) bool {
nodeFields := fields.Set{
"displayName": node.DisplayName,
"templateName": node.TemplateName,
"templateName": GetTemplateFromNode(node),
"phase": string(node.Phase),
"name": node.Name,
"id": node.ID,
Expand Down

0 comments on commit 27a3159

Please sign in to comment.