[Enterprise Search] Fix broken indices page when an index with alias is closed (#158871)

## Summary

Fix indices page when an index is closed. Added a check to see if the
index is closed by checking the flag
`index.settings.index.verified_before_close` is set to true

### Screen Recording


f818b92d-8947-4764-aed9-a8a191cba2e0

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Saarika Bhasi 2023-06-02 10:57:42 -04:00 committed by GitHub
parent 48c8aa6419
commit 7c8ddd0ec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View file

@ -303,7 +303,11 @@ describe('fetch indices lib functions', () => {
expect(mockClient.asCurrentUser.indices.get).toHaveBeenCalledWith({
expand_wildcards: ['open'],
features: ['aliases', 'settings'],
filter_path: ['*.aliases', '*.settings.index.hidden'],
filter_path: [
'*.aliases',
'*.settings.index.hidden',
'*.settings.index.verified_before_close',
],
index: '*search*',
});
@ -363,7 +367,11 @@ describe('fetch indices lib functions', () => {
expect(mockClient.asCurrentUser.indices.get).toHaveBeenCalledWith({
expand_wildcards: ['hidden', 'all'],
features: ['aliases', 'settings'],
filter_path: ['*.aliases', '*.settings.index.hidden'],
filter_path: [
'*.aliases',
'*.settings.index.hidden',
'*.settings.index.verified_before_close',
],
index: '*',
});

View file

@ -92,6 +92,12 @@ export const getIndexDataMapper = (totalIndexData: TotalIndexData) => {
function isHidden(index: IndicesIndexState): boolean {
return index.settings?.index?.hidden === true || index.settings?.index?.hidden === 'true';
}
function isClosed(index: IndicesIndexState): boolean {
return (
index.settings?.index?.verified_before_close === true ||
index.settings?.index?.verified_before_close === 'true'
);
}
export const getIndexData = async (
client: IScopedClusterClient,
@ -107,14 +113,19 @@ export const getIndexData = async (
features: ['aliases', 'settings'],
// only get specified index properties from ES to keep the response under 536MB
// node.js string length limit: https://github.com/nodejs/node/issues/33960
filter_path: ['*.aliases', '*.settings.index.hidden'],
filter_path: ['*.aliases', '*.settings.index.hidden', '*.settings.index.verified_before_close'],
index: onlyShowSearchOptimizedIndices ? 'search-*' : indexPattern,
});
const allIndexNames = returnHiddenIndices
? Object.keys(allIndexMatches)
? Object.keys(allIndexMatches).filter(
(indexName) => allIndexMatches[indexName] && !isClosed(allIndexMatches[indexName])
)
: Object.keys(allIndexMatches).filter(
(indexName) => allIndexMatches[indexName] && !isHidden(allIndexMatches[indexName])
(indexName) =>
allIndexMatches[indexName] &&
!isHidden(allIndexMatches[indexName]) &&
!isClosed(allIndexMatches[indexName])
);
const indexNames =
onlyShowSearchOptimizedIndices && searchQuery