mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Close https://github.com/elastic/kibana/issues/209471 # Backport This will backport the following commits from `8.18` to `main`: - [[UA] Preserve hidden status of original index during reindexing (#209512)](https://github.com/elastic/kibana/pull/209512) <!--- Backport version: 9.6.4 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jean-Louis Leysens","email":"jeanlouis.leysens@elastic.co"},"sourceCommit":{"committedDate":"2025-02-04T13:20:51Z","message":"[UA] Preserve hidden status of original index during reindexing (#209512)","sha":"ed5b521cb491ccb4e1491190f221209de1c2a90f","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","Feature:Upgrade Assistant","backport:skip"],"title":"[UA] Preserve hidden status of original index during reindexing","number":209512,"url":"https://github.com/elastic/kibana/pull/209512","mergeCommit":{"message":"[UA] Preserve hidden status of original index during reindexing (#209512)","sha":"ed5b521cb491ccb4e1491190f221209de1c2a90f"}},"sourceBranch":"8.18","suggestedTargetBranches":[],"targetPullRequestStates":[]}] BACKPORT-->
This commit is contained in:
parent
23d926f096
commit
b8742125f5
2 changed files with 42 additions and 3 deletions
|
@ -799,18 +799,42 @@ describe('reindexService', () => {
|
|||
expect(updatedOp.attributes.lastCompletedStep).toEqual(ReindexStep.aliasCreated);
|
||||
expect(clusterClient.asCurrentUser.indices.updateAliases).toHaveBeenCalledWith({
|
||||
actions: [
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myIndex' } },
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myIndex', is_hidden: false } },
|
||||
{ remove_index: { index: 'myIndex' } },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it.each([true, 'true'])(
|
||||
'switches aliases, passing on hidden status of index to alias if defined (hidden value: %p)',
|
||||
async (hidden) => {
|
||||
clusterClient.asCurrentUser.indices.getAlias.mockResponseOnce({
|
||||
myIndex: { aliases: {} },
|
||||
});
|
||||
clusterClient.asCurrentUser.indices.getSettings.mockResponseOnce({
|
||||
myIndex: { settings: { index: { hidden } } },
|
||||
});
|
||||
clusterClient.asCurrentUser.indices.updateAliases.mockResponseOnce({
|
||||
acknowledged: true,
|
||||
});
|
||||
const updatedOp = await service.processNextStep(reindexOp);
|
||||
expect(updatedOp.attributes.lastCompletedStep).toEqual(ReindexStep.aliasCreated);
|
||||
expect(clusterClient.asCurrentUser.indices.updateAliases).toHaveBeenCalledWith({
|
||||
actions: [
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myIndex', is_hidden: true } },
|
||||
{ remove_index: { index: 'myIndex' } },
|
||||
],
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('moves existing aliases over to new index', async () => {
|
||||
clusterClient.asCurrentUser.indices.getAlias.mockResponseOnce({
|
||||
myIndex: {
|
||||
aliases: {
|
||||
myAlias: {},
|
||||
myFilteredAlias: { filter: { term: { https: true } } },
|
||||
myHiddenAlias: { is_hidden: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -821,7 +845,7 @@ describe('reindexService', () => {
|
|||
expect(updatedOp.attributes.lastCompletedStep).toEqual(ReindexStep.aliasCreated);
|
||||
expect(clusterClient.asCurrentUser.indices.updateAliases).toHaveBeenCalledWith({
|
||||
actions: [
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myIndex' } },
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myIndex', is_hidden: false } },
|
||||
{ remove_index: { index: 'myIndex' } },
|
||||
{ add: { index: 'myIndex-reindex-0', alias: 'myAlias' } },
|
||||
{
|
||||
|
@ -831,6 +855,13 @@ describe('reindexService', () => {
|
|||
filter: { term: { https: true } },
|
||||
},
|
||||
},
|
||||
{
|
||||
add: {
|
||||
index: 'myIndex-reindex-0',
|
||||
alias: 'myHiddenAlias',
|
||||
is_hidden: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
|
|
@ -349,6 +349,12 @@ export const reindexServiceFactory = (
|
|||
return response[indexName]?.aliases ?? {};
|
||||
};
|
||||
|
||||
const isIndexHidden = async (indexName: string) => {
|
||||
const response = await esClient.indices.getSettings({ index: indexName });
|
||||
const isHidden = response[indexName]?.settings?.index?.hidden;
|
||||
return isHidden === true || isHidden === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
* Restores the original index settings in the new index that had other defaults for reindexing performance reasons
|
||||
* @param reindexOp
|
||||
|
@ -391,9 +397,11 @@ export const reindexServiceFactory = (
|
|||
add: { index: newIndexName, alias: aliasName, ...existingAliases[aliasName] },
|
||||
}));
|
||||
|
||||
const isHidden = await isIndexHidden(indexName);
|
||||
|
||||
const aliasResponse = await esClient.indices.updateAliases({
|
||||
actions: [
|
||||
{ add: { index: newIndexName, alias: indexName } },
|
||||
{ add: { index: newIndexName, alias: indexName, is_hidden: isHidden } },
|
||||
{ remove_index: { index: indexName } },
|
||||
...extraAliases,
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue