Skip to content

Commit 381e083

Browse files
Revert "[Reporting] ILM policy for managing reporting indices (#100130)" (#101358)
This reverts commit 662fe74. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/reporting/server/lib/store/store.ts
1 parent ce25bf2 commit 381e083

4 files changed

Lines changed: 12 additions & 114 deletions

File tree

x-pack/plugins/reporting/server/lib/store/report_ilm_policy.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

x-pack/plugins/reporting/server/lib/store/store.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
99
import { ElasticsearchClient } from 'src/core/server';
10-
import { elasticsearchServiceMock } from 'src/core/server/mocks';
1110
import { ReportingCore } from '../../';
1211
import {
1312
createMockConfigSchema,
@@ -17,8 +16,6 @@ import {
1716
import { Report } from './report';
1817
import { ReportingStore } from './store';
1918

20-
const { createApiResponse } = elasticsearchServiceMock;
21-
2219
describe('ReportingStore', () => {
2320
const mockLogger = createMockLevelLogger();
2421
let mockCore: ReportingCore;
@@ -342,40 +339,4 @@ describe('ReportingStore', () => {
342339
]
343340
`);
344341
});
345-
346-
describe('start', () => {
347-
it('creates an ILM policy for managing reporting indices if there is not already one', async () => {
348-
mockEsClient.ilm.getLifecycle.mockRejectedValueOnce(createApiResponse({ statusCode: 404 }));
349-
mockEsClient.ilm.putLifecycle.mockResolvedValueOnce(createApiResponse());
350-
351-
const store = new ReportingStore(mockCore, mockLogger);
352-
await store.start();
353-
354-
expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ policy: 'kibana-reporting' });
355-
expect(mockEsClient.ilm.putLifecycle.mock.calls[0][0]).toMatchInlineSnapshot(`
356-
Object {
357-
"body": Object {
358-
"policy": Object {
359-
"phases": Object {
360-
"hot": Object {
361-
"actions": Object {},
362-
},
363-
},
364-
},
365-
},
366-
"policy": "kibana-reporting",
367-
}
368-
`);
369-
});
370-
371-
it('does not create an ILM policy for managing reporting indices if one already exists', async () => {
372-
mockEsClient.ilm.getLifecycle.mockResolvedValueOnce(createApiResponse());
373-
374-
const store = new ReportingStore(mockCore, mockLogger);
375-
await store.start();
376-
377-
expect(mockEsClient.ilm.getLifecycle).toHaveBeenCalledWith({ policy: 'kibana-reporting' });
378-
expect(mockEsClient.ilm.putLifecycle).not.toHaveBeenCalled();
379-
});
380-
});
381342
});

x-pack/plugins/reporting/server/lib/store/store.ts

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { ReportingCore } from '../../';
1111
import { indexTimestamp } from './index_timestamp';
1212
import { mapping } from './mapping';
1313
import { Report } from './report';
14-
import { reportingIlmPolicy } from './report_ilm_policy';
1514

1615
const checkReportIsEditable = (report: Report) => {
1716
if (!report._id || !report._index) {
@@ -53,22 +52,19 @@ export class ReportingStore {
5352
return exists;
5453
}
5554

55+
const indexSettings = {
56+
number_of_shards: 1,
57+
auto_expand_replicas: '0-1',
58+
};
59+
const body = {
60+
settings: indexSettings,
61+
mappings: {
62+
properties: mapping,
63+
},
64+
};
65+
5666
try {
57-
await client.indices.create({
58-
index: indexName,
59-
body: {
60-
settings: {
61-
number_of_shards: 1,
62-
auto_expand_replicas: '0-1',
63-
lifecycle: {
64-
name: this.ilmPolicyName,
65-
},
66-
},
67-
mappings: {
68-
properties: mapping,
69-
},
70-
},
71-
});
67+
await client.indices.create({ index: indexName, body });
7268

7369
return true;
7470
} catch (error) {
@@ -115,44 +111,6 @@ export class ReportingStore {
115111
return client.indices.refresh({ index });
116112
}
117113

118-
private readonly ilmPolicyName = 'kibana-reporting';
119-
120-
private async doesIlmPolicyExist(): Promise<boolean> {
121-
const client = await this.getClient();
122-
try {
123-
await client.ilm.getLifecycle({ policy: this.ilmPolicyName });
124-
return true;
125-
} catch (e) {
126-
if (e.statusCode === 404) {
127-
return false;
128-
}
129-
throw e;
130-
}
131-
}
132-
133-
/**
134-
* Function to be called during plugin start phase. This ensures the environment is correctly
135-
* configured for storage of reports.
136-
*/
137-
public async start() {
138-
const client = await this.getClient();
139-
try {
140-
if (await this.doesIlmPolicyExist()) {
141-
this.logger.debug(`Found ILM policy ${this.ilmPolicyName}; skipping creation.`);
142-
return;
143-
}
144-
this.logger.info(`Creating ILM policy for managing reporting indices: ${this.ilmPolicyName}`);
145-
await client.ilm.putLifecycle({
146-
policy: this.ilmPolicyName,
147-
body: reportingIlmPolicy,
148-
});
149-
} catch (e) {
150-
this.logger.error('Error in start phase');
151-
this.logger.error(e.body.error);
152-
throw e;
153-
}
154-
}
155-
156114
public async addReport(report: Report): Promise<Report> {
157115
let index = report._index;
158116
if (!index) {

x-pack/plugins/reporting/server/plugin.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ export class ReportingPlugin
113113
logger: this.logger,
114114
});
115115

116-
// Note: this must be called after ReportingCore.pluginStart
117-
await store.start();
118-
119116
this.logger.debug('Start complete');
120117
})().catch((e) => {
121118
this.logger.error(`Error in Reporting start, reporting may not function properly`);

0 commit comments

Comments
 (0)