mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[6.7][UA] Security index should reindex into ".security-7" (#31996)
Security indices are whitelisted and it has been decided to stick with the naming convention introduced in the 5.6 Upgrade Assistant. Related https://github.com/elastic/elasticsearch/pull/39337 Related https://github.com/elastic/elasticsearch/issues/39284 Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co> * Always match against .security-{6,7} * Use constant for security source index name Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
84a0579d4e
commit
bab2369873
3 changed files with 51 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
import {
|
||||
CURRENT_MAJOR_VERSION,
|
||||
NEXT_MAJOR_VERSION,
|
||||
PREV_MAJOR_VERSION,
|
||||
} from 'x-pack/plugins/upgrade_assistant/common/version';
|
||||
import { ReindexWarning } from '../../../common/types';
|
||||
|
@ -183,6 +184,12 @@ describe('sourceNameForIndex', () => {
|
|||
'.myInternalIndex'
|
||||
);
|
||||
});
|
||||
|
||||
it('parses security index', () => {
|
||||
expect(sourceNameForIndex('.security-6')).toEqual('.security');
|
||||
expect(sourceNameForIndex('.security-7')).toEqual('.security');
|
||||
expect(sourceNameForIndex('.security')).toEqual('.security');
|
||||
});
|
||||
});
|
||||
|
||||
describe('generateNewIndexName', () => {
|
||||
|
@ -215,6 +222,16 @@ describe('generateNewIndexName', () => {
|
|||
`.reindexed-v${CURRENT_MAJOR_VERSION}-myInternalIndex`
|
||||
);
|
||||
});
|
||||
|
||||
it('maintains security naming convention when aleady re-indexed', () => {
|
||||
expect(generateNewIndexName(`.security-${CURRENT_MAJOR_VERSION}`)).toEqual(
|
||||
`.security-${NEXT_MAJOR_VERSION}`
|
||||
);
|
||||
});
|
||||
|
||||
it('maintains security naming convention', () => {
|
||||
expect(generateNewIndexName(`.security`)).toEqual(`.security-${NEXT_MAJOR_VERSION}`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getReindexWarnings', () => {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { flow, omit } from 'lodash';
|
||||
import {
|
||||
CURRENT_MAJOR_VERSION,
|
||||
NEXT_MAJOR_VERSION,
|
||||
PREV_MAJOR_VERSION,
|
||||
} from 'x-pack/plugins/upgrade_assistant/common/version';
|
||||
import { ReindexWarning } from '../../../common/types';
|
||||
|
@ -19,6 +20,14 @@ export interface ParsedIndexName {
|
|||
cleanBaseName: string;
|
||||
}
|
||||
|
||||
// the security indices must be whitelisted and follow the pattern set forth in v5
|
||||
const SECURITY_MATCHER = new RegExp(`^.security(-[67])?$`);
|
||||
const SECURITY_SOURCE = '.security';
|
||||
|
||||
// in 5.6 the upgrade assistant appended to the index, in 6.7+ we prepend to
|
||||
// avoid conflicts with index patterns/templates/etc
|
||||
const REINDEXED_MATCHER = new RegExp(`(-reindexed-v5$|reindexed-v${PREV_MAJOR_VERSION}-)`, 'g');
|
||||
|
||||
/**
|
||||
* Validates, and updates deprecated settings and mappings to be applied to the
|
||||
* new updated index.
|
||||
|
@ -45,11 +54,13 @@ export const sourceNameForIndex = (indexName: string): string => {
|
|||
const internal = matches[1] || '';
|
||||
const baseName = matches[2];
|
||||
|
||||
// in 5.6 the upgrade assistant appended to the index, in 6.7+ we prepend to
|
||||
// avoid conflicts with index patterns/templates/etc
|
||||
const reindexedMatcher = new RegExp(`(-reindexed-v5$|reindexed-v${PREV_MAJOR_VERSION}-)`, 'g');
|
||||
// special handling for security index
|
||||
if (indexName.match(SECURITY_MATCHER)) {
|
||||
return SECURITY_SOURCE;
|
||||
}
|
||||
|
||||
const cleanBaseName = baseName.replace(REINDEXED_MATCHER, '');
|
||||
|
||||
const cleanBaseName = baseName.replace(reindexedMatcher, '');
|
||||
return `${internal}${cleanBaseName}`;
|
||||
};
|
||||
|
||||
|
@ -63,6 +74,10 @@ export const generateNewIndexName = (indexName: string): string => {
|
|||
const sourceName = sourceNameForIndex(indexName);
|
||||
const currentVersion = `reindexed-v${CURRENT_MAJOR_VERSION}`;
|
||||
|
||||
if (sourceName === SECURITY_SOURCE) {
|
||||
return `${SECURITY_SOURCE}-${NEXT_MAJOR_VERSION}`;
|
||||
}
|
||||
|
||||
return indexName.startsWith('.')
|
||||
? `.${currentVersion}-${sourceName.substr(1)}`
|
||||
: `${currentVersion}-${sourceName}`;
|
||||
|
|
|
@ -64,6 +64,21 @@ describe('ReindexActions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it(`replaces .security-6 with .security-7`, async () => {
|
||||
await actions.createReindexOp('.security-6');
|
||||
expect(client.create).toHaveBeenCalledWith(REINDEX_OP_TYPE, {
|
||||
indexName: '.security-6',
|
||||
newIndexName: `.security-7`,
|
||||
status: ReindexStatus.inProgress,
|
||||
lastCompletedStep: ReindexStep.created,
|
||||
locked: null,
|
||||
reindexTaskId: null,
|
||||
reindexTaskPercComplete: null,
|
||||
errorMessage: null,
|
||||
runningReindexCount: null,
|
||||
});
|
||||
});
|
||||
|
||||
it(`prepends reindexed-v${CURRENT_MAJOR_VERSION} to new name, preserving leading period`, async () => {
|
||||
await actions.createReindexOp('.internalIndex');
|
||||
expect(client.create).toHaveBeenCalledWith(REINDEX_OP_TYPE, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue