mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[EventLog] don't use legacy template APIs during initialization (#164747)
resolves https://github.com/elastic/kibana/issues/164731 ## Summary This removes the check for a legacy index template for the event log for the current version it wants to create. This was presumably done this way, to allow for the switch from legacy to component templates. But it's not really needed, since each stack version creates new index templates. So, removing the check should be fine. ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: Tiago Costa <tiago.costa@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
43b0fab35c
commit
bcb99825a7
2 changed files with 2 additions and 24 deletions
|
@ -168,38 +168,17 @@ describe('buffering documents', () => {
|
|||
describe('doesIndexTemplateExist', () => {
|
||||
test('should call cluster with proper arguments', async () => {
|
||||
await clusterClientAdapter.doesIndexTemplateExist('foo');
|
||||
expect(clusterClient.indices.existsTemplate).toHaveBeenCalledWith({
|
||||
expect(clusterClient.indices.existsIndexTemplate).toHaveBeenCalledWith({
|
||||
name: 'foo',
|
||||
});
|
||||
});
|
||||
|
||||
test('should return true when call cluster to legacy template API returns true', async () => {
|
||||
clusterClient.indices.existsTemplate.mockResponse(true);
|
||||
clusterClient.indices.existsIndexTemplate.mockResponse(false);
|
||||
await expect(clusterClientAdapter.doesIndexTemplateExist('foo')).resolves.toEqual(true);
|
||||
});
|
||||
|
||||
test('should return true when call cluster to index template API returns true', async () => {
|
||||
clusterClient.indices.existsTemplate.mockResponse(false);
|
||||
clusterClient.indices.existsIndexTemplate.mockResponse(true);
|
||||
await expect(clusterClientAdapter.doesIndexTemplateExist('foo')).resolves.toEqual(true);
|
||||
});
|
||||
|
||||
test('should return false when both call cluster calls returns false', async () => {
|
||||
clusterClient.indices.existsTemplate.mockResponse(false);
|
||||
clusterClient.indices.existsIndexTemplate.mockResponse(false);
|
||||
await expect(clusterClientAdapter.doesIndexTemplateExist('foo')).resolves.toEqual(false);
|
||||
});
|
||||
|
||||
test('should throw error when call cluster to legacy template API throws an error', async () => {
|
||||
clusterClient.indices.existsTemplate.mockRejectedValue(new Error('Fail'));
|
||||
await expect(
|
||||
clusterClientAdapter.doesIndexTemplateExist('foo')
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"error checking existence of index template: Fail"`
|
||||
);
|
||||
});
|
||||
|
||||
test('should throw error when call cluster to index template API throws an error', async () => {
|
||||
clusterClient.indices.existsIndexTemplate.mockRejectedValue(new Error('Fail'));
|
||||
await expect(
|
||||
|
|
|
@ -181,9 +181,8 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
|
|||
public async doesIndexTemplateExist(name: string): Promise<boolean> {
|
||||
try {
|
||||
const esClient = await this.elasticsearchClientPromise;
|
||||
const legacyResult = await esClient.indices.existsTemplate({ name });
|
||||
const indexTemplateResult = await esClient.indices.existsIndexTemplate({ name });
|
||||
return (legacyResult as boolean) || (indexTemplateResult as boolean);
|
||||
return indexTemplateResult as boolean;
|
||||
} catch (err) {
|
||||
throw new Error(`error checking existence of index template: ${err.message}`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue