From 239632e3dbc4392b7a4410022a88ca9906e68666 Mon Sep 17 00:00:00 2001 From: Spencer Judge Date: Mon, 24 Mar 2025 14:22:32 -0700 Subject: [PATCH 1/2] Expose parent and root execution in describe call --- temporalcli/commands.workflow_view.go | 4 ++ temporalcli/commands.workflow_view_test.go | 59 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index 94e721dec..dc31856ce 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -117,6 +117,8 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount int64 HistoryLength int64 HistorySize int64 + ParentExecution *common.WorkflowExecution `cli:",cardOmitEmpty"` + RootExecution *common.WorkflowExecution `cli:",cardOmitEmpty"` }{ WorkflowId: info.Execution.WorkflowId, RunId: info.Execution.RunId, @@ -132,6 +134,8 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount: info.StateTransitionCount, HistoryLength: info.HistoryLength, HistorySize: info.HistorySizeBytes, + ParentExecution: info.ParentExecution, + RootExecution: info.RootExecution, }, printer.StructuredOptions{}) extendedInfo := resp.WorkflowExtendedInfo diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 31bfc96af..2c8a97bbd 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -993,3 +993,62 @@ func (s *SharedServerSuite) TestWorkflow_Describe_WorkflowMetadata() { s.NotNil(jsonOut.ExecutionConfig.UserMetadata.Summary) s.NotNil(jsonOut.ExecutionConfig.UserMetadata.Details) } + +func (s *SharedServerSuite) TestWorkflow_Describe_RootWorkflow() { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + if input.(string) == "child" { + return "done", nil + } + ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ + StartToCloseTimeout: 10 * time.Second, + }) + childHandle := workflow.ExecuteChildWorkflow(ctx, DevWorkflow, "child") + var childWE workflow.Execution + err := childHandle.GetChildWorkflowExecution().Get(ctx, &childWE) + if err != nil { + return nil, err + } + err = childHandle.Get(ctx, nil) + if err != nil { + return nil, err + } + return childWE.ID, err + }) + + run, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, + DevWorkflow, + "ignored", + ) + s.NoError(err) + var wfRes string + err = run.Get(s.Context, &wfRes) + s.NoError(err) + + // Text + res := s.Execute( + "workflow", "describe", + "--address", s.Address(), + "-w", wfRes, + ) + s.NoError(res.Err) + out := res.Stdout.String() + s.ContainsOnSameLine(out, "ParentExecution", run.GetID()) + s.ContainsOnSameLine(out, "RootExecution", run.GetID()) + + // JSON + res = s.Execute( + "workflow", "describe", + "-o", "json", + "--address", s.Address(), + "-w", wfRes, + ) + s.NoError(res.Err) + var jsonOut workflowservice.DescribeWorkflowExecutionResponse + s.NoError(temporalcli.UnmarshalProtoJSONWithOptions(res.Stdout.Bytes(), &jsonOut, true)) + s.Equal(run.GetID(), jsonOut.WorkflowExecutionInfo.ParentExecution.GetWorkflowId()) + s.Equal(run.GetRunID(), jsonOut.WorkflowExecutionInfo.ParentExecution.GetRunId()) + s.Equal(run.GetID(), jsonOut.WorkflowExecutionInfo.RootExecution.GetWorkflowId()) + s.Equal(run.GetRunID(), jsonOut.WorkflowExecutionInfo.RootExecution.GetRunId()) +} From 8687ea9b6af750dd9ae55315eaed786fd6524d24 Mon Sep 17 00:00:00 2001 From: Spencer Judge Date: Tue, 25 Mar 2025 10:39:52 -0700 Subject: [PATCH 2/2] Break out fields --- temporalcli/commands.workflow_view.go | 12 ++++++++---- temporalcli/commands.workflow_view_test.go | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index dc31856ce..9bfb5337f 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -117,8 +117,10 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount int64 HistoryLength int64 HistorySize int64 - ParentExecution *common.WorkflowExecution `cli:",cardOmitEmpty"` - RootExecution *common.WorkflowExecution `cli:",cardOmitEmpty"` + ParentWorkflowId string `cli:",cardOmitEmpty"` + ParentRunId string `cli:",cardOmitEmpty"` + RootWorkflowId string `cli:",cardOmitEmpty"` + RootRunId string `cli:",cardOmitEmpty"` }{ WorkflowId: info.Execution.WorkflowId, RunId: info.Execution.RunId, @@ -134,8 +136,10 @@ func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []strin StateTransitionCount: info.StateTransitionCount, HistoryLength: info.HistoryLength, HistorySize: info.HistorySizeBytes, - ParentExecution: info.ParentExecution, - RootExecution: info.RootExecution, + ParentWorkflowId: info.GetParentExecution().GetWorkflowId(), + ParentRunId: info.GetParentExecution().GetRunId(), + RootWorkflowId: info.GetRootExecution().GetWorkflowId(), + RootRunId: info.GetRootExecution().GetRunId(), }, printer.StructuredOptions{}) extendedInfo := resp.WorkflowExtendedInfo diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 2c8a97bbd..a758b7815 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -1034,8 +1034,10 @@ func (s *SharedServerSuite) TestWorkflow_Describe_RootWorkflow() { ) s.NoError(res.Err) out := res.Stdout.String() - s.ContainsOnSameLine(out, "ParentExecution", run.GetID()) - s.ContainsOnSameLine(out, "RootExecution", run.GetID()) + s.ContainsOnSameLine(out, "ParentWorkflowId", run.GetID()) + s.ContainsOnSameLine(out, "ParentRunId", run.GetRunID()) + s.ContainsOnSameLine(out, "RootWorkflowId", run.GetID()) + s.ContainsOnSameLine(out, "RootRunId", run.GetRunID()) // JSON res = s.Execute(