[ML] Fixing annotations alias checks (#58722)
This commit is contained in:
parent
91330d2493
commit
38067da7ac
2 changed files with 13 additions and 15 deletions
|
@ -1,11 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { IScopedClusterClient } from 'src/core/server';
|
|
||||||
|
|
||||||
export function isAnnotationsFeatureAvailable(
|
|
||||||
callAsCurrentUser: IScopedClusterClient['callAsCurrentUser']
|
|
||||||
): boolean;
|
|
|
@ -4,6 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* 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 { mlLog } from '../../client/log';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -16,23 +17,31 @@ import {
|
||||||
// - ML_ANNOTATIONS_INDEX_PATTERN index is present
|
// - ML_ANNOTATIONS_INDEX_PATTERN index is present
|
||||||
// - ML_ANNOTATIONS_INDEX_ALIAS_READ alias is present
|
// - ML_ANNOTATIONS_INDEX_ALIAS_READ alias is present
|
||||||
// - ML_ANNOTATIONS_INDEX_ALIAS_WRITE alias is present
|
// - ML_ANNOTATIONS_INDEX_ALIAS_WRITE alias is present
|
||||||
export async function isAnnotationsFeatureAvailable(callAsCurrentUser) {
|
export async function isAnnotationsFeatureAvailable(callAsCurrentUser: APICaller) {
|
||||||
try {
|
try {
|
||||||
const indexParams = { index: ML_ANNOTATIONS_INDEX_PATTERN };
|
const indexParams = { index: ML_ANNOTATIONS_INDEX_PATTERN };
|
||||||
|
|
||||||
const annotationsIndexExists = await callAsCurrentUser('indices.exists', indexParams);
|
const annotationsIndexExists = await callAsCurrentUser('indices.exists', indexParams);
|
||||||
if (!annotationsIndexExists) return false;
|
if (!annotationsIndexExists) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const annotationsReadAliasExists = await callAsCurrentUser('indices.existsAlias', {
|
const annotationsReadAliasExists = await callAsCurrentUser('indices.existsAlias', {
|
||||||
|
index: ML_ANNOTATIONS_INDEX_ALIAS_READ,
|
||||||
name: 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', {
|
const annotationsWriteAliasExists = await callAsCurrentUser('indices.existsAlias', {
|
||||||
|
index: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
|
||||||
name: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
|
name: ML_ANNOTATIONS_INDEX_ALIAS_WRITE,
|
||||||
});
|
});
|
||||||
if (!annotationsWriteAliasExists) return false;
|
if (!annotationsWriteAliasExists) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
mlLog.info('Disabling ML annotations feature because the index/alias integrity check failed.');
|
mlLog.info('Disabling ML annotations feature because the index/alias integrity check failed.');
|
||||||
return false;
|
return false;
|
Loading…
Reference in a new issue