Skip to content

Commit

Permalink
[Enterprise Search] Fix broken indices page when an index with alias …
Browse files Browse the repository at this point in the history
…is closed (elastic#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

https://github.com/elastic/kibana/assets/55930906/f818b92d-8947-4764-aed9-a8a191cba2e0

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 7c8ddd0)
  • Loading branch information
saarikabhasi committed Jun 2, 2023
1 parent f4375f6 commit 9915cc6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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*',
});

Expand Down Expand Up @@ -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: '*',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 9915cc6

Please sign in to comment.