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

[Cases] Case action: Error handling and retries #173012

Merged
merged 83 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
0e1bfb0
Register the case action
cnasikas Oct 9, 2023
4777f9c
Register the cases oracle
cnasikas Oct 9, 2023
65a88fa
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Oct 9, 2023
eeb35a6
Calculate the hash of the record ID
cnasikas Oct 9, 2023
649dea9
Merge branch 'register_case_action' of github.com:cnasikas/kibana int…
cnasikas Oct 10, 2023
4491476
Get oracle record
cnasikas Oct 10, 2023
f4a81a1
Rename folder
cnasikas Oct 11, 2023
5822d73
Sort grouping definition
cnasikas Oct 11, 2023
df77537
Increase counter
cnasikas Oct 11, 2023
9955239
Change grouping to record
cnasikas Oct 12, 2023
58bc3d6
Make the rule ID optional in the key
cnasikas Oct 12, 2023
581819a
Better types
cnasikas Oct 13, 2023
449a1b7
Add version when updating
cnasikas Oct 13, 2023
c210a0c
Improve types
cnasikas Oct 13, 2023
c802637
Fix tests
cnasikas Oct 13, 2023
b249032
Merge branch 'case_action' into register_case_action
cnasikas Oct 16, 2023
c120c97
Add model version and improve mapping
cnasikas Oct 16, 2023
043a9fe
Fix tests
cnasikas Oct 16, 2023
a9db13f
Fix mapping test
cnasikas Oct 16, 2023
32af9e3
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Oct 16, 2023
90acabf
Merge branch 'case_action' into register_case_action
cnasikas Oct 18, 2023
b7605b7
Merge branch 'register_case_action' of github.com:cnasikas/kibana int…
cnasikas Oct 18, 2023
7b27008
Define connector params initial schema
cnasikas Oct 17, 2023
13fd013
Bulk get records
cnasikas Oct 17, 2023
69a8778
Group alerts and bulk get oracle records
cnasikas Oct 17, 2023
e5c73a3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 18, 2023
1ba6117
Bulk create records
cnasikas Oct 18, 2023
bf8a32d
Merge branch 'ca_part_2' of github.com:cnasikas/kibana into ca_part_2
cnasikas Oct 18, 2023
c6982a5
Add TODOs
cnasikas Oct 19, 2023
f184a08
Move bulkGetOrCreateOracleRecords logic to the connector
cnasikas Oct 20, 2023
40f865e
Generate case ids
cnasikas Oct 20, 2023
f70bf1e
Get service with a factory
cnasikas Oct 21, 2023
04805ac
Fix docs
cnasikas Oct 21, 2023
a3d47e6
Merge branch 'main' into saf_get_instance
cnasikas Oct 21, 2023
3988644
Merge branch 'saf_get_instance' into ca_part_2
cnasikas Oct 21, 2023
af1b8ae
Pass the cases client to the case connector
cnasikas Oct 21, 2023
4c6f5ae
Attach alerts to a case
cnasikas Oct 23, 2023
a7f1ba1
Merge branch 'case_action' into register_case_action
cnasikas Oct 23, 2023
a283b93
Merge branch 'register_case_action' into ca_part_2
cnasikas Oct 23, 2023
8fd2a84
Merge branch 'case_action' into ca_part_2
cnasikas Nov 8, 2023
13012eb
Merge branch 'case_action' into ca_part_2
cnasikas Nov 8, 2023
c8e82e5
Bulk create non existing cases
cnasikas Nov 8, 2023
1ead049
Improve the case request
cnasikas Nov 10, 2023
b31c167
Small improvements
cnasikas Nov 10, 2023
2621c7d
Add time window to schema
cnasikas Nov 10, 2023
ab42f16
Merge branch 'case_action' into ca_time_window
cnasikas Nov 15, 2023
ad14c3f
Merge branch 'case_action' into ca_time_window
cnasikas Nov 22, 2023
5d340aa
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 22, 2023
b20ef53
Upsert oracle records
cnasikas Nov 23, 2023
b3806ef
Increase the counter when the time window has passed
cnasikas Nov 29, 2023
27209ac
Merge branch 'case_action' into ca_time_window
cnasikas Nov 29, 2023
346735b
Merge branch 'ca_time_window' of github.com:cnasikas/kibana into ca_t…
cnasikas Nov 29, 2023
7e5989e
Add more tests
cnasikas Nov 29, 2023
2a44c29
Add reopenClosedCases to params
cnasikas Dec 1, 2023
0c0d572
Rename cases client method
cnasikas Dec 1, 2023
432a4dc
Reopen closed cases
cnasikas Dec 1, 2023
e5ed0dd
Fix issue with concat
cnasikas Dec 4, 2023
70f153d
Merge branch 'case_action' into ca_reopen_cases
cnasikas Dec 6, 2023
1c9fd6f
Open new cases when the cases are closed
cnasikas Dec 6, 2023
a24f562
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Dec 6, 2023
48f107c
Add more tests about the time window validation
cnasikas Dec 7, 2023
e545acf
Move handling the time window outside of upserting oracle records
cnasikas Dec 7, 2023
9eca674
Merge branch 'ca_reopen_cases' of github.com:cnasikas/kibana into ca_…
cnasikas Dec 7, 2023
b5fecef
Merge branch 'case_action' into ca_time_window
cnasikas Dec 8, 2023
81ab220
Fix bug with Regex
cnasikas Dec 8, 2023
003c285
Merge branch 'ca_time_window' into ca_reopen_cases
cnasikas Dec 8, 2023
1a6636a
Merge branch 'case_action' into ca_reopen_cases
cnasikas Dec 8, 2023
d64c6f9
Do not attach alerts to cases that will surpress the limit
cnasikas Dec 8, 2023
22bf49b
Handle errors
cnasikas Dec 10, 2023
6d17751
Move execution to another class
cnasikas Dec 10, 2023
70a3417
Create jitter full backoff
cnasikas Dec 11, 2023
19ffd27
Merge branch 'case_action' into ca_error_handling
cnasikas Dec 20, 2023
9ff2617
Merge branch 'case_action' into ca_error_handling
cnasikas Dec 20, 2023
69e90d6
Add tests for jitter
cnasikas Dec 21, 2023
aac09db
Create retry service
cnasikas Dec 21, 2023
3b9c564
Retry the execution of the connector
cnasikas Dec 21, 2023
8af3c0f
Add retry tests
cnasikas Dec 22, 2023
f214254
Move mock data to the mock file
cnasikas Dec 24, 2023
96afd98
Create test helpers
cnasikas Dec 24, 2023
cae023b
Merge branch 'case_action' into ca_error_handling
cnasikas Jan 7, 2024
a901029
Remove formatting in current_fields
cnasikas Jan 8, 2024
00a2871
Small improvements
cnasikas Jan 9, 2024
068678a
PR feedback
cnasikas Jan 11, 2024
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
932 changes: 134 additions & 798 deletions x-pack/plugins/cases/server/connectors/cases/cases_connector.test.ts
Copy link
Member Author

Choose a reason for hiding this comment

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

The test tests only how the executor is called and the retry logic. All the executor logic moved to cases_connector_executor.test.ts.

Large diffs are not rendered by default.

586 changes: 34 additions & 552 deletions x-pack/plugins/cases/server/connectors/cases/cases_connector.ts
Copy link
Member Author

Choose a reason for hiding this comment

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

All logic of the executor moved to cases_connector_executor.ts.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { CaseError } from '../../common/error';

export class CasesConnectorError extends Error {
public readonly statusCode: number;

constructor(message: string, statusCode: number) {
super(message);

this.statusCode = statusCode;
}
}

export const isCasesConnectorError = (error: unknown): error is CasesConnectorError =>
error instanceof CasesConnectorError;

export const isCasesClientError = (error: unknown): error is CaseError =>
error instanceof CaseError;
Loading