Skip to content

Commit

Permalink
[8.8] [Enterprise Search] Fix broken indices page when an index with …
Browse files Browse the repository at this point in the history
…alias is closed (#158871) (#158938)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Enterprise Search] Fix broken indices page when an index with alias
is closed (#158871)](#158871)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Saarika
Bhasi","email":"55930906+saarikabhasi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-06-02T14:57:42Z","message":"[Enterprise
Search] Fix broken indices page when an index with alias is closed
(#158871)\n\n## Summary\r\n\r\nFix indices page when an index is closed.
Added a check to see if the\r\nindex is closed by checking the
flag\r\n`index.settings.index.verified_before_close` is set to
true\r\n\r\n### Screen
Recording\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/55930906/f818b92d-8947-4764-aed9-a8a191cba2e0\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7c8ddd0ec54442f3556141c9d8897b28c1539e70","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:EnterpriseSearch","v8.9.0","v8.8.1"],"number":158871,"url":"#158871
Search] Fix broken indices page when an index with alias is closed
(#158871)\n\n## Summary\r\n\r\nFix indices page when an index is closed.
Added a check to see if the\r\nindex is closed by checking the
flag\r\n`index.settings.index.verified_before_close` is set to
true\r\n\r\n### Screen
Recording\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/55930906/f818b92d-8947-4764-aed9-a8a191cba2e0\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7c8ddd0ec54442f3556141c9d8897b28c1539e70"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"#158871
Search] Fix broken indices page when an index with alias is closed
(#158871)\n\n## Summary\r\n\r\nFix indices page when an index is closed.
Added a check to see if the\r\nindex is closed by checking the
flag\r\n`index.settings.index.verified_before_close` is set to
true\r\n\r\n### Screen
Recording\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/55930906/f818b92d-8947-4764-aed9-a8a191cba2e0\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"7c8ddd0ec54442f3556141c9d8897b28c1539e70"}},{"branch":"8.8","label":"v8.8.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Saarika Bhasi <55930906+saarikabhasi@users.noreply.github.com>
  • Loading branch information
kibanamachine and saarikabhasi committed Jun 2, 2023
1 parent b3a45ca commit 21beb7d
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 21beb7d

Please sign in to comment.