Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Fixing annotations alias checks #58722

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions x-pack/plugins/ml/server/lib/check_annotations/index.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { APICaller } from 'src/core/server';
import { mlLog } from '../../client/log';

import {
Expand All @@ -16,23 +17,31 @@ import {
// - ML_ANNOTATIONS_INDEX_PATTERN index is present
// - ML_ANNOTATIONS_INDEX_ALIAS_READ alias is present
// - ML_ANNOTATIONS_INDEX_ALIAS_WRITE alias is present
export async function isAnnotationsFeatureAvailable(callAsCurrentUser) {
export async function isAnnotationsFeatureAvailable(callAsCurrentUser: APICaller) {
try {
const indexParams = { index: ML_ANNOTATIONS_INDEX_PATTERN };

const annotationsIndexExists = await callAsCurrentUser('indices.exists', indexParams);
if (!annotationsIndexExists) return false;
if (!annotationsIndexExists) {
return false;
}

const annotationsReadAliasExists = await callAsCurrentUser('indices.existsAlias', {
index: ML_ANNOTATIONS_INDEX_ALIAS_READ,
name: ML_ANNOTATIONS_INDEX_ALIAS_READ,
});

if (!annotationsReadAliasExists) return false;
if (!annotationsReadAliasExists) {
return false;
}

const annotationsWriteAliasExists = await callAsCurrentUser('indices.existsAlias', {
index: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
name: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
});
if (!annotationsWriteAliasExists) return false;
if (!annotationsWriteAliasExists) {
return false;
}
} catch (err) {
mlLog.info('Disabling ML annotations feature because the index/alias integrity check failed.');
return false;
Expand Down