diff --git a/service/worker/diagnostics/parent_workflow.go b/service/worker/diagnostics/parent_workflow.go index 63e697e7b50..2235b2d7958 100644 --- a/service/worker/diagnostics/parent_workflow.go +++ b/service/worker/diagnostics/parent_workflow.go @@ -49,13 +49,17 @@ type DiagnosticsStarterWorkflowInput struct { } type DiagnosticsStarterWorkflowResult struct { - DiagnosticsResult *DiagnosticsWorkflowResult + DiagnosticsResult *DiagnosticsWorkflowResult + DiagnosticsCompleted bool } func (w *dw) DiagnosticsStarterWorkflow(ctx workflow.Context, params DiagnosticsStarterWorkflowInput) (*DiagnosticsStarterWorkflowResult, error) { - var result DiagnosticsWorkflowResult + var diagWfResult DiagnosticsWorkflowResult + workflowResult := DiagnosticsStarterWorkflowResult{ + DiagnosticsResult: &diagWfResult, + } err := workflow.SetQueryHandler(ctx, queryDiagnosticsReport, func() (DiagnosticsStarterWorkflowResult, error) { - return DiagnosticsStarterWorkflowResult{DiagnosticsResult: &result}, nil + return workflowResult, nil }) if err != nil { return nil, err @@ -74,10 +78,11 @@ func (w *dw) DiagnosticsStarterWorkflow(ctx workflow.Context, params Diagnostics } childWfStart = workflow.Now(ctx) - err = future.Get(ctx, &result) + err = future.Get(ctx, &diagWfResult) if err != nil { return nil, fmt.Errorf("Workflow Diagnostics failed: %w", err) } + workflowResult.DiagnosticsCompleted = true childWfEnd = workflow.Now(ctx) activityOptions := workflow.ActivityOptions{ @@ -91,7 +96,7 @@ func (w *dw) DiagnosticsStarterWorkflow(ctx workflow.Context, params Diagnostics WorkflowID: params.WorkflowID, RunID: params.RunID, Identity: params.Identity, - IssueType: getIssueType(result), + IssueType: getIssueType(diagWfResult), DiagnosticsWorkflowID: childWfExec.ID, DiagnosticsRunID: childWfExec.RunID, DiagnosticsStartTime: childWfStart, @@ -101,7 +106,7 @@ func (w *dw) DiagnosticsStarterWorkflow(ctx workflow.Context, params Diagnostics return nil, fmt.Errorf("EmitUsageLogs: %w", err) } - return &DiagnosticsStarterWorkflowResult{DiagnosticsResult: &result}, nil + return &workflowResult, nil } func getIssueType(result DiagnosticsWorkflowResult) string { diff --git a/service/worker/diagnostics/workflow_test.go b/service/worker/diagnostics/workflow_test.go index de80491f607..665f38443c5 100644 --- a/service/worker/diagnostics/workflow_test.go +++ b/service/worker/diagnostics/workflow_test.go @@ -141,10 +141,12 @@ func (s *diagnosticsWorkflowTestSuite) TestWorkflow() { s.NoError(s.workflowEnv.GetWorkflowResult(&result)) s.ElementsMatch(timeoutIssues, result.DiagnosticsResult.Timeouts.Issues) s.ElementsMatch(timeoutRootCause, result.DiagnosticsResult.Timeouts.RootCause) + s.True(result.DiagnosticsCompleted) queriedResult := s.queryDiagnostics() s.ElementsMatch(queriedResult.DiagnosticsResult.Timeouts.Issues, result.DiagnosticsResult.Timeouts.Issues) s.ElementsMatch(queriedResult.DiagnosticsResult.Timeouts.RootCause, result.DiagnosticsResult.Timeouts.RootCause) + s.True(queriedResult.DiagnosticsCompleted) } func (s *diagnosticsWorkflowTestSuite) TestWorkflow_Error() {