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

[Wf-Diagnotics] Update Diagnostics workflow result to provide a completion signal #6635

Merged
merged 1 commit into from
Jan 21, 2025
Merged
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
17 changes: 11 additions & 6 deletions service/worker/diagnostics/parent_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions service/worker/diagnostics/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading