Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store podname in nodestatus #12503

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/jsonschema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions cmd/argo/commands/common/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,23 +477,28 @@ func renderChild(w *tabwriter.Writer, wf *wfv1.Workflow, nInfo renderNode, depth
}

// Main method to print information of node in get
func printNode(w *tabwriter.Writer, node wfv1.NodeStatus, wfName, nodePrefix string, getArgs GetFlags, podNameVersion util.PodNameVersion) {
nodeName := node.Name
func printNode(w *tabwriter.Writer, node wfv1.NodeStatus, wfName string, nodePrefix string, getArgs GetFlags, podNameVersion util.PodNameVersion) {
fmtNodeName := fmt.Sprintf("%s %s", JobStatusIconMap[node.Phase], node.DisplayName)
if node.IsActiveSuspendNode() {
fmtNodeName = fmt.Sprintf("%s %s", NodeTypeIconMap[node.Type], node.DisplayName)
}
templateName := util.GetTemplateFromNode(node)
fmtTemplateName := ""
if node.TemplateRef != nil {
fmtTemplateName = fmt.Sprintf("%s/%s", node.TemplateRef.Name, node.TemplateRef.Template)
} else if node.TemplateName != "" {
fmtTemplateName = node.TemplateName
}
templateName := util.GetTemplateFromNode(node)
var args []interface{}
duration := humanize.RelativeDurationShort(node.StartedAt.Time, node.FinishedAt.Time)
if node.Type == wfv1.NodeTypePod {
podName := util.GeneratePodName(wfName, nodeName, templateName, node.ID, podNameVersion)
podName := ""
if node.PodName != nil {
podName = *node.PodName
} else {
expectedPodName := util.GeneratePodName(wfName, node.Name, templateName, node.ID, podNameVersion)
panic("podName absent expected " + expectedPodName + " for " + node.Name)
}
Comment on lines +496 to +501
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not the desirable behaviour, there might be cases where the pod has not been created yet.
What should we do in this case?

args = []interface{}{nodePrefix, fmtNodeName, fmtTemplateName, podName, duration, node.Message, ""}
} else {
args = []interface{}{nodePrefix, fmtNodeName, fmtTemplateName, "", "", node.Message, ""}
Expand Down
19 changes: 18 additions & 1 deletion cmd/argo/commands/common/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func TestPrintNode(t *testing.T) {
Time: time.Now(),
}

podName := util.GeneratePodName(workflowName, nodeName, nodeTemplateName, nodeID, util.GetPodNameVersion())

// Node without TemplateRef
node := wfv1.NodeStatus{
Name: nodeName,
Expand All @@ -71,6 +73,7 @@ func TestPrintNode(t *testing.T) {
FinishedAt: timestamp,
Message: nodeMessage,
TemplateName: nodeTemplateName,
PodName: &podName,
}
node.HostNodeName = kubernetesNodeName
// derive expected pod name:
Expand Down Expand Up @@ -119,8 +122,10 @@ func TestPrintNode(t *testing.T) {
Name: nodeTemplateRefName,
Template: nodeTemplateRefName,
}

templateName = util.GetTemplateFromNode(node)
expectedPodName = util.GeneratePodName(workflowName, nodeName, templateName, nodeID, util.GetPodNameVersion())
node.PodName = &expectedPodName
testPrintNodeImpl(t, fmt.Sprintf("%s %s\t%s/%s\t%s\t%s\t%s\t%s\n", NodeTypeIconMap[wfv1.NodeTypeSuspend], nodeName, nodeTemplateRefName, nodeTemplateRefName, "", "", nodeMessage, ""), node, getArgs)

getArgs.Output = "wide"
Expand Down Expand Up @@ -240,6 +245,7 @@ status:
many-items-z26lj-753834747:
boundaryID: many-items-z26lj
displayName: sleep(8:eight)
podName: many-items-z26lj-sleep-753834747
finishedAt: "2020-06-02T16:04:42Z"
id: many-items-z26lj-753834747
name: many-items-z26lj[0].sleep(8:eight)
Expand All @@ -250,6 +256,7 @@ status:
many-items-z26lj-1052882686:
boundaryID: many-items-z26lj
displayName: sleep(10:ten)
podName: many-items-z26lj-sleep-1052882686
finishedAt: "2020-06-02T16:04:45Z"
id: many-items-z26lj-1052882686
name: many-items-z26lj[0].sleep(10:ten)
Expand Down Expand Up @@ -284,6 +291,7 @@ status:
many-items-z26lj-1774150289:
boundaryID: many-items-z26lj
displayName: sleep(3:three)
podName: many-items-z26lj-sleep-1774150289
finishedAt: "2020-06-02T16:04:54Z"
id: many-items-z26lj-1774150289
name: many-items-z26lj[0].sleep(3:three)
Expand All @@ -297,13 +305,15 @@ status:
finishedAt: "2020-06-02T16:04:48Z"
id: many-items-z26lj-1939921510
name: many-items-z26lj[0].sleep(0:zero)
podName: many-items-z26lj-sleep-1939921510
phase: Succeeded
startedAt: "2020-06-02T16:04:21Z"
templateName: sleep
type: Pod
many-items-z26lj-1942531647:
boundaryID: many-items-z26lj
displayName: sleep(5:five)
podName: many-items-z26lj-sleep-1942531647
finishedAt: "2020-06-02T16:04:47Z"
id: many-items-z26lj-1942531647
name: many-items-z26lj[0].sleep(5:five)
Expand All @@ -317,13 +327,15 @@ status:
finishedAt: "2020-06-02T16:04:53Z"
id: many-items-z26lj-2156977535
name: many-items-z26lj[0].sleep(1:one)
podName: many-items-z26lj-sleep-2156977535
phase: Succeeded
startedAt: "2020-06-02T16:04:21Z"
templateName: sleep
type: Pod
many-items-z26lj-2619926859:
boundaryID: many-items-z26lj
displayName: sleep(9:nine)
podName: many-items-z26lj-sleep-2619926859
finishedAt: "2020-06-02T16:04:40Z"
id: many-items-z26lj-2619926859
name: many-items-z26lj[0].sleep(9:nine)
Expand All @@ -334,6 +346,7 @@ status:
many-items-z26lj-3011405271:
boundaryID: many-items-z26lj
displayName: sleep(11:eleven)
podName: many-items-z26lj-sleep-3011405271
finishedAt: "2020-06-02T16:04:44Z"
id: many-items-z26lj-3011405271
name: many-items-z26lj[0].sleep(11:eleven)
Expand All @@ -344,6 +357,7 @@ status:
many-items-z26lj-3031375822:
boundaryID: many-items-z26lj
displayName: sleep(7:seven)
podName: many-items-z26lj-sleep-3031375822
finishedAt: "2020-06-02T16:04:57Z"
id: many-items-z26lj-3031375822
name: many-items-z26lj[0].sleep(7:seven)
Expand All @@ -354,6 +368,7 @@ status:
many-items-z26lj-3126938806:
boundaryID: many-items-z26lj
displayName: sleep(12:twelve)
podName: many-items-z26lj-sleep-3126938806
finishedAt: "2020-06-02T16:04:59Z"
id: many-items-z26lj-3126938806
name: many-items-z26lj[0].sleep(12:twelve)
Expand All @@ -364,6 +379,7 @@ status:
many-items-z26lj-3178865096:
boundaryID: many-items-z26lj
displayName: sleep(6:six)
podName: many-items-z26lj-sleep-3178865096
finishedAt: "2020-06-02T16:04:56Z"
id: many-items-z26lj-3178865096
name: many-items-z26lj[0].sleep(6:six)
Expand All @@ -374,6 +390,7 @@ status:
many-items-z26lj-3409403178:
boundaryID: many-items-z26lj
displayName: sleep(2:two)
podName: many-items-z26lj-sleep-3409403178
finishedAt: "2020-06-02T16:04:51Z"
id: many-items-z26lj-3409403178
name: many-items-z26lj[0].sleep(2:two)
Expand All @@ -384,6 +401,7 @@ status:
many-items-z26lj-3491220632:
boundaryID: many-items-z26lj
displayName: sleep(4:four)
podName: many-items-z26lj-sleep-3491220632
finishedAt: "2020-06-02T16:04:50Z"
id: many-items-z26lj-3491220632
name: many-items-z26lj[0].sleep(4:four)
Expand All @@ -394,7 +412,6 @@ status:
phase: Succeeded
startedAt: "2020-06-02T16:04:21Z"
`, &wf)

output := PrintWorkflowHelper(&wf, GetFlags{})

// derive expected pod name:
Expand Down
1 change: 1 addition & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,7 @@ NodeStatus contains status information about an individual node in the workflow
|`outputs`|[`Outputs`](#outputs)|Outputs captures output parameter values and artifact locations produced by this template invocation|
|`phase`|`string`|Phase a simple, high-level summary of where the node is in its lifecycle. Can be used as a state machine. Will be one of these values "Pending", "Running" before the node is completed, or "Succeeded", "Skipped", "Failed", "Error", or "Omitted" as a final state.|
|`podIP`|`string`|PodIP captures the IP of the pod for daemoned steps|
|`podName`|`string`|PodName is the name of the pod this node is executed on|
|`progress`|`string`|Progress to completion|
|`resourcesDuration`|`Map< integer , int64 >`|ResourcesDuration is indicative, but not accurate, resource duration. This is populated when the nodes completes.|
|`startedAt`|[`Time`](#time)|Time at which this node started|
Expand Down
2 changes: 2 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflows.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading