Skip to content

Commit

Permalink
[Response Ops][Alerting] Reusable functions for FAAD resource install…
Browse files Browse the repository at this point in the history
…ation (#152849)

Resolves #152490

## Summary

This PR refactors the resource installation methods in `AlertsService`
to be reusable library functions. It exports them from the alerting
plugin and changes the rule registry resource installer to use them as
well.

## To Verify
1. Run this branch with `enableFrameworkAlerts: true`. Verify that we
can create a detection rule in the default space & a different space and
generate a rule preview. The logs should show that the rule registry
creates the resources for the preview indices and for indices in the
non-default space.
2. Verify that when running this branch on rule registry rules from
`main` or a previous version, the rules continue to run successfully.

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
ymao1 and kibanamachine authored Mar 20, 2023
1 parent 098456a commit 49a0996
Show file tree
Hide file tree
Showing 19 changed files with 1,831 additions and 868 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,16 @@ const GetAliasResponse = {
};

const IlmPutBody = {
body: {
policy: {
_meta: {
managed: true,
},
phases: {
hot: {
actions: {
rollover: {
max_age: '30d',
max_primary_shard_size: '50gb',
},
policy: {
_meta: {
managed: true,
},
phases: {
hot: {
actions: {
rollover: {
max_age: '30d',
max_primary_shard_size: '50gb',
},
},
},
Expand Down Expand Up @@ -212,7 +210,6 @@ describe('Alerts Service', () => {
);

expect(clusterClient.ilm.putLifecycle).toHaveBeenCalled();
expect(clusterClient.cluster.putComponentTemplate).not.toHaveBeenCalled();
});

test('should log error and set initialized to false if creating/updating common component template throws error', async () => {
Expand All @@ -232,7 +229,6 @@ describe('Alerts Service', () => {
);

expect(clusterClient.ilm.putLifecycle).toHaveBeenCalled();
expect(clusterClient.cluster.putComponentTemplate).toHaveBeenCalledTimes(1);
});

test('should update index template field limit and retry initialization if creating/updating common component template fails with field limit error', async () => {
Expand Down
Loading

0 comments on commit 49a0996

Please sign in to comment.