Skip to content

Commit 8ba44eb

Browse files
authored
change api endpoint and throw error (#65790)
1 parent 37aad5c commit 8ba44eb

File tree

1 file changed

+5
-17
lines changed
  • x-pack/plugins/ingest_manager/server/services/epm/kibana/index_pattern

1 file changed

+5
-17
lines changed

x-pack/plugins/ingest_manager/server/services/epm/kibana/index_pattern/install.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,11 @@ export const ensureDefaultIndices = async (callCluster: CallESAsCurrentUser) =>
372372
Promise.all(
373373
Object.keys(IndexPatternType).map(async indexPattern => {
374374
const defaultIndexPatternName = indexPattern + INDEX_PATTERN_PLACEHOLDER_SUFFIX;
375-
const indexExists = await doesIndexExist(defaultIndexPatternName, callCluster);
375+
const indexExists = await callCluster('indices.exists', { index: defaultIndexPatternName });
376376
if (!indexExists) {
377377
try {
378-
await callCluster('transport.request', {
379-
method: 'PUT',
380-
path: `/${defaultIndexPatternName}`,
378+
await callCluster('indices.create', {
379+
index: defaultIndexPatternName,
381380
body: {
382381
mappings: {
383382
properties: {
@@ -387,20 +386,9 @@ export const ensureDefaultIndices = async (callCluster: CallESAsCurrentUser) =>
387386
},
388387
});
389388
} catch (putErr) {
390-
throw new Error(`${defaultIndexPatternName} could not be created`);
389+
// throw new Error(`${defaultIndexPatternName} could not be created`);
390+
throw new Error(putErr);
391391
}
392392
}
393393
})
394394
);
395-
396-
export const doesIndexExist = async (indexName: string, callCluster: CallESAsCurrentUser) => {
397-
try {
398-
await callCluster('transport.request', {
399-
method: 'HEAD',
400-
path: indexName,
401-
});
402-
return true;
403-
} catch (err) {
404-
return false;
405-
}
406-
};

0 commit comments

Comments
 (0)