Skip to content

Commit

Permalink
[Wf-Diagnostics] rootcause simple worker service caused activity and …
Browse files Browse the repository at this point in the history
…workflow failures (cadence-workflow#6351)

* [Wf-Diagnostics] rootcause simple service side activity and workflow failures

* Update interface.go
  • Loading branch information
sankari165 authored Oct 11, 2024
1 parent 03e34b9 commit 77c61f2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
13 changes: 11 additions & 2 deletions service/worker/diagnostics/invariant/failure/failure.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ func fetchIdentity(attr *types.WorkflowExecutionFailedEventAttributes, events []
return ""
}

func (f *failure) RootCause(ctx context.Context, results []invariant.InvariantCheckResult) ([]invariant.InvariantRootCauseResult, error) {
return nil, nil
func (f *failure) RootCause(ctx context.Context, issues []invariant.InvariantCheckResult) ([]invariant.InvariantRootCauseResult, error) {
result := make([]invariant.InvariantRootCauseResult, 0)
for _, issue := range issues {
if issue.Reason == CustomError.String() || issue.Reason == PanicError.String() {
result = append(result, invariant.InvariantRootCauseResult{
RootCause: invariant.RootCauseTypeServiceSideIssue,
Metadata: issue.Metadata,
})
}
}
return result, nil
}
36 changes: 36 additions & 0 deletions service/worker/diagnostics/invariant/failure/failure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,39 @@ func failedWfHistory() *types.GetWorkflowExecutionHistoryResponse {
},
}
}

func Test__RootCause(t *testing.T) {
metadata := failureMetadata{
Identity: "localhost",
}
metadataInBytes, err := json.Marshal(metadata)
require.NoError(t, err)
testCases := []struct {
name string
input []invariant.InvariantCheckResult
expectedResult []invariant.InvariantRootCauseResult
err error
}{
{
name: "customer side failure",
input: []invariant.InvariantCheckResult{
{
InvariantType: ActivityFailed.String(),
Reason: CustomError.String(),
Metadata: metadataInBytes,
}},
expectedResult: []invariant.InvariantRootCauseResult{{
RootCause: invariant.RootCauseTypeServiceSideIssue,
Metadata: metadataInBytes,
}},
err: nil,
},
}
inv := NewInvariant(Params{})
for _, tc := range testCases {
result, err := inv.RootCause(context.Background(), tc.input)
require.Equal(t, tc.err, err)
require.Equal(t, len(tc.expectedResult), len(result))
require.ElementsMatch(t, tc.expectedResult, result)
}
}
1 change: 1 addition & 0 deletions service/worker/diagnostics/invariant/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
RootCauseTypePollersStatus RootCause = "There are pollers for the tasklist. Check backlog status"
RootCauseTypeHeartBeatingNotEnabled RootCause = "HeartBeating not enabled for activity"
RootCauseTypeHeartBeatingEnabledMissingHeartbeat RootCause = "HeartBeating enabled for activity but timed out due to missing heartbeat"
RootCauseTypeServiceSideIssue RootCause = "There is an issue in the worker service code that is causing this failure. Check identity for service logs"
)

func (r RootCause) String() string {
Expand Down

0 comments on commit 77c61f2

Please sign in to comment.