Skip to content

Commit a7aedd8

Browse files
committed
[ML] Fixing annotations alias checks
1 parent 967bef7 commit a7aedd8

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

x-pack/plugins/ml/server/lib/check_annotations/index.d.ts

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

x-pack/plugins/ml/server/lib/check_annotations/index.js renamed to x-pack/plugins/ml/server/lib/check_annotations/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { APICaller } from 'src/core/server';
78
import { mlLog } from '../../client/log';
89

910
import {
@@ -16,23 +17,31 @@ import {
1617
// - ML_ANNOTATIONS_INDEX_PATTERN index is present
1718
// - ML_ANNOTATIONS_INDEX_ALIAS_READ alias is present
1819
// - ML_ANNOTATIONS_INDEX_ALIAS_WRITE alias is present
19-
export async function isAnnotationsFeatureAvailable(callAsCurrentUser) {
20+
export async function isAnnotationsFeatureAvailable(callAsCurrentUser: APICaller) {
2021
try {
2122
const indexParams = { index: ML_ANNOTATIONS_INDEX_PATTERN };
2223

2324
const annotationsIndexExists = await callAsCurrentUser('indices.exists', indexParams);
24-
if (!annotationsIndexExists) return false;
25+
if (!annotationsIndexExists) {
26+
return false;
27+
}
2528

2629
const annotationsReadAliasExists = await callAsCurrentUser('indices.existsAlias', {
30+
index: ML_ANNOTATIONS_INDEX_ALIAS_READ,
2731
name: ML_ANNOTATIONS_INDEX_ALIAS_READ,
2832
});
2933

30-
if (!annotationsReadAliasExists) return false;
34+
if (!annotationsReadAliasExists) {
35+
return false;
36+
}
3137

3238
const annotationsWriteAliasExists = await callAsCurrentUser('indices.existsAlias', {
39+
index: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
3340
name: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
3441
});
35-
if (!annotationsWriteAliasExists) return false;
42+
if (!annotationsWriteAliasExists) {
43+
return false;
44+
}
3645
} catch (err) {
3746
mlLog.info('Disabling ML annotations feature because the index/alias integrity check failed.');
3847
return false;

0 commit comments

Comments
 (0)