[Upgrade Assistant] Remove reindex logic that is no longer applicable (#91193)

This commit is contained in:
Alison Goryachev 2021-02-23 08:42:59 -05:00 committed by GitHub
parent 7593a911ca
commit 77bc230901
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 121 additions and 193 deletions

View file

@ -93,10 +93,6 @@ export interface ReindexOperation extends SavedObjectAttributes {
export type ReindexSavedObject = SavedObject<ReindexOperation>;
export enum ReindexWarning {
// 6.0 -> 7.0 warnings, now unused
allField = 0,
booleanFields = 1,
// 7.0 -> 8.0 warnings
apmReindex,

View file

@ -27,88 +27,26 @@ exports[`WarningsFlyoutStep renders 1`] = `
checkedIds={
Object {
"reindexWarning-0": false,
"reindexWarning-1": false,
}
}
description={
<FormattedMessage
defaultMessage="The {allField} meta field is no longer supported in 7.0. Reindexing removes the {allField} field in the new index. Ensure that no application code or scripts reply on this field."
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.allFieldWarningDetail"
values={
Object {
"allField": <EuiCode>
_all
</EuiCode>,
}
}
defaultMessage="Starting in version 7.0.0, APM data will be represented in the Elastic Common Schema. Historical APM data will not visible until it's reindexed."
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningDetail"
values={Object {}}
/>
}
documentationUrl="https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_the_literal__all_literal_meta_field_is_now_disabled_by_default"
documentationUrl="https://www.elastic.co/guide/en/observability/master/whats-new.html"
label={
<FormattedMessage
defaultMessage="{allField} will be removed"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.allFieldWarningTitle"
values={
Object {
"allField": <EuiCode>
_all
</EuiCode>,
}
}
defaultMessage="This index will be converted to ECS format"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.apmReindexWarningTitle"
values={Object {}}
/>
}
onChange={[Function]}
warning={0}
/>
<WarningCheckbox
checkedIds={
Object {
"reindexWarning-0": false,
"reindexWarning-1": false,
}
}
description={
<FormattedMessage
defaultMessage="If a document contain a boolean field that is neither {true} or {false} (for example, {yes}, {on}, {one}), reindexing converts these fields to {true} or {false}. Ensure that no application code or scripts rely on boolean fields in the deprecated format."
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.booleanFieldsWarningDetail"
values={
Object {
"false": <EuiCode>
false
</EuiCode>,
"on": <EuiCode>
"on"
</EuiCode>,
"one": <EuiCode>
1
</EuiCode>,
"true": <EuiCode>
true
</EuiCode>,
"yes": <EuiCode>
"yes"
</EuiCode>,
}
}
/>
}
documentationUrl="https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_field"
label={
<FormattedMessage
defaultMessage="Boolean data in {_source} might change"
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.booleanFieldsWarningTitle"
values={
Object {
"_source": <EuiCode>
_source
</EuiCode>,
}
}
/>
}
onChange={[Function]}
warning={1}
/>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup

View file

@ -29,7 +29,7 @@ describe('ChecklistFlyout', () => {
status: undefined,
reindexTaskPercComplete: null,
errorMessage: null,
reindexWarnings: [ReindexWarning.allField],
reindexWarnings: [ReindexWarning.apmReindex],
hasRequiredPrivileges: true,
} as ReindexState,
};

View file

@ -28,7 +28,7 @@ jest.mock('../../../../../../app_context', () => {
describe('WarningsFlyoutStep', () => {
const defaultProps = {
advanceNextStep: jest.fn(),
warnings: [ReindexWarning.allField, ReindexWarning.booleanFields],
warnings: [ReindexWarning.apmReindex],
closeFlyout: jest.fn(),
renderGlobalCallouts: jest.fn(),
};
@ -48,11 +48,7 @@ describe('WarningsFlyoutStep', () => {
button.simulate('click');
expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();
wrapper.find(`input#${idForWarning(ReindexWarning.allField)}`).simulate('change');
button.simulate('click');
expect(defaultProps.advanceNextStep).not.toHaveBeenCalled();
wrapper.find(`input#${idForWarning(ReindexWarning.booleanFields)}`).simulate('change');
wrapper.find(`input#${idForWarning(ReindexWarning.apmReindex)}`).simulate('change');
button.simulate('click');
expect(defaultProps.advanceNextStep).toHaveBeenCalled();
});

View file

@ -12,7 +12,6 @@ import {
EuiButtonEmpty,
EuiCallOut,
EuiCheckbox,
EuiCode,
EuiFlexGroup,
EuiFlexItem,
EuiFlyoutBody,
@ -103,10 +102,8 @@ export const WarningsFlyoutStep: React.FunctionComponent<WarningsConfirmationFly
const { docLinks } = useAppContext();
const { ELASTIC_WEBSITE_URL } = docLinks;
const esDocBasePath = `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference`;
const observabilityDocBasePath = `${ELASTIC_WEBSITE_URL}guide/en/observability`;
// TODO: Revisit warnings returned for 8.0 upgrade; many of these are likely obselete now
return (
<>
<EuiFlyoutBody>
@ -131,35 +128,6 @@ export const WarningsFlyoutStep: React.FunctionComponent<WarningsConfirmationFly
<EuiSpacer />
{warnings.includes(ReindexWarning.allField) && (
<WarningCheckbox
checkedIds={checkedIds}
onChange={onChange}
warning={ReindexWarning.allField}
label={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.allFieldWarningTitle"
defaultMessage="{allField} will be removed"
values={{
allField: <EuiCode>_all</EuiCode>,
}}
/>
}
description={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.allFieldWarningDetail"
defaultMessage="The {allField} meta field is no longer supported in 7.0. Reindexing removes
the {allField} field in the new index. Ensure that no application code or scripts reply on
this field."
values={{
allField: <EuiCode>_all</EuiCode>,
}}
/>
}
documentationUrl={`${esDocBasePath}/6.0/breaking_60_mappings_changes.html#_the_literal__all_literal_meta_field_is_now_disabled_by_default`}
/>
)}
{warnings.includes(ReindexWarning.apmReindex) && (
<WarningCheckbox
checkedIds={checkedIds}
@ -181,37 +149,6 @@ export const WarningsFlyoutStep: React.FunctionComponent<WarningsConfirmationFly
documentationUrl={`${observabilityDocBasePath}/master/whats-new.html`}
/>
)}
{warnings.includes(ReindexWarning.booleanFields) && (
<WarningCheckbox
checkedIds={checkedIds}
onChange={onChange}
warning={ReindexWarning.booleanFields}
label={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.booleanFieldsWarningTitle"
defaultMessage="Boolean data in {_source} might change"
values={{ _source: <EuiCode>_source</EuiCode> }}
/>
}
description={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.booleanFieldsWarningDetail"
defaultMessage="If a document contain a boolean field that is neither {true} or {false}
(for example, {yes}, {on}, {one}), reindexing converts these fields to {true} or {false}.
Ensure that no application code or scripts rely on boolean fields in the deprecated format."
values={{
true: <EuiCode>true</EuiCode>,
false: <EuiCode>false</EuiCode>,
yes: <EuiCode>&quot;yes&quot;</EuiCode>,
on: <EuiCode>&quot;on&quot;</EuiCode>,
one: <EuiCode>1</EuiCode>,
}}
/>
}
documentationUrl={`${esDocBasePath}/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_field`}
/>
)}
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">

View file

@ -37,14 +37,29 @@ describe('transformFlatSettings', () => {
// Settings that should get preserved
'index.number_of_replicas': '1',
'index.number_of_shards': '5',
// Blacklisted settings
'index.uuid': 'i66b9149a-00ee-42d9-8ca1-85ae927924bf',
'index.allocation.existing_shards_allocator': 'gateway_allocator',
'index.blocks.write': 'true',
'index.creation_date': '1547052614626',
'index.legacy': '6',
'index.mapping.single_type': 'true',
'index.frozen': 'true',
'index.history.uuid': 'i66b9149a-00ee-42d9-8ca1-85ae9279234gh',
'index.merge.enabled': 'true',
'index.provided_name': 'test1',
'index.resize.source.name': 'resizeName',
'index.resize.source.uuid': 'k34b9149a-00ee-42d9-8ca1-85ae9279234zs',
'index.routing.allocation.initial_recovery._id': '1',
'index.search.throttled': 'true',
'index.source_only': 'true',
'index.shrink.source.name': 'shrinkSourceName',
'index.shrink.source.uuid': 'q34b9149a-00ee-42d9-8ca1-85ae234324df',
'index.store.snapshot.repository_name': 'repoName',
'index.store.snapshot.snapshot_name': 'snapshotName',
'index.store.snapshot.snapshot_uuid': 'f345c9149a-00ee-42d9-8ca1-85ae234324df',
'index.store.snapshot.index_name': 'snapshotIndexName',
'index.store.snapshot.index_uuid': 'h764f9149a-00ee-42d9-8ca1-85ae234324af',
'index.uuid': 'i66b9149a-00ee-42d9-8ca1-85ae927924bf',
'index.verified_before_close': 'true',
'index.version.created': '123123',
'index.version.upgraded': '123123',
},
@ -58,6 +73,52 @@ describe('transformFlatSettings', () => {
mappings: {},
});
});
it('does not allow index.mapper.dynamic to be set', () => {
expect(() =>
transformFlatSettings({
settings: {
'index.mapper.dynamic': 'true',
},
mappings: {},
})
).toThrowError(`'index.mapper.dynamic' is no longer supported.`);
});
it('does not allow index.merge.policy.reclaim_deletes_weight to be set', () => {
expect(() =>
transformFlatSettings({
settings: {
'index.merge.policy.reclaim_deletes_weight': '2.0d',
},
mappings: {},
})
).toThrowError(`'index.merge.policy.reclaim_deletes_weight' is no longer supported.`);
});
it('does not allow index.force_memory_term_dictionary to be set', () => {
expect(() =>
transformFlatSettings({
settings: {
'index.force_memory_term_dictionary': 'false',
},
mappings: {},
})
).toThrowError(`'index.force_memory_term_dictionary' is no longer supported.`);
});
it('does not index.max_adjacency_matrix_filters to be set', () => {
expect(() =>
transformFlatSettings({
settings: {
'index.max_adjacency_matrix_filters': '1024',
},
mappings: {},
})
).toThrowError(
`'index.max_adjacency_matrix_filters' is no longer supported; use 'indices.query.bool.max_clause_count' as an alternative.`
);
});
});
describe('sourceNameForIndex', () => {
@ -73,11 +134,6 @@ describe('sourceNameForIndex', () => {
expect(sourceNameForIndex('myIndex')).toEqual('myIndex');
});
it('excludes appended v5 reindexing string from newIndexName', () => {
expect(sourceNameForIndex('myIndex-reindexed-v5')).toEqual('myIndex');
expect(sourceNameForIndex('.myInternalIndex-reindexed-v5')).toEqual('.myInternalIndex');
});
it(`replaces reindexed-v${prevMajor} with reindexed-v${currentMajor} in newIndexName`, () => {
expect(sourceNameForIndex(`reindexed-v${prevMajor}-myIndex`)).toEqual('myIndex');
expect(sourceNameForIndex(`.reindexed-v${prevMajor}-myInternalIndex`)).toEqual(
@ -101,16 +157,6 @@ describe('generateNewIndexName', () => {
expect(generateNewIndexName('myIndex')).toEqual(`reindexed-v${currentMajor}-myIndex`);
});
it('excludes appended v5 reindexing string from generateNewIndexName', () => {
expect(generateNewIndexName('myIndex-reindexed-v5')).toEqual(
`reindexed-v${currentMajor}-myIndex`
);
expect(generateNewIndexName('.myInternalIndex-reindexed-v5')).toEqual(
`.reindexed-v${currentMajor}-myInternalIndex`
);
});
it(`replaces reindexed-v${prevMajor} with reindexed-v${currentMajor} in generateNewIndexName`, () => {
expect(generateNewIndexName(`reindexed-v${prevMajor}-myIndex`)).toEqual(
`reindexed-v${currentMajor}-myIndex`

View file

@ -43,12 +43,8 @@ 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${versionService.getPrevMajorVersion()}-)`,
'g'
);
// in 6.7+ we prepend to avoid conflicts with index patterns/templates/etc
const reindexedMatcher = new RegExp(`reindexed-v${versionService.getPrevMajorVersion()}-`, 'g');
const cleanBaseName = baseName.replace(reindexedMatcher, '');
return `${internal}${cleanBaseName}`;
@ -83,23 +79,60 @@ export const getReindexWarnings = (flatSettings: FlatSettings): ReindexWarning[]
const removeUnsettableSettings = (settings: FlatSettings['settings']) =>
omit(settings, [
'index.uuid',
// Private ES settings
'index.allocation.existing_shards_allocator',
'index.blocks.write',
'index.creation_date',
'index.legacy',
'index.mapping.single_type',
'index.frozen',
'index.history.uuid',
'index.merge.enabled',
'index.provided_name',
'index.resize.source.name',
'index.resize.source.uuid',
'index.routing.allocation.initial_recovery._id',
'index.version.created',
'index.version.upgraded',
'index.search.throttled',
'index.source_only',
'index.shrink.source.name',
'index.shrink.source.uuid',
'index.store.snapshot.repository_name',
'index.store.snapshot.snapshot_name',
'index.store.snapshot.snapshot_uuid',
'index.store.snapshot.index_name',
'index.store.snapshot.index_uuid',
'index.uuid',
'index.verified_before_close',
'index.version.created',
// Deprecated in 9.0
'index.version.upgraded',
]);
const validateSettings = (settings: FlatSettings['settings']) => {
if (settings['index.mapper.dynamic']) {
throw new Error(`'index.mapper.dynamic' is no longer supported.`);
}
if (settings['index.merge.policy.reclaim_deletes_weight']) {
throw new Error(`'index.merge.policy.reclaim_deletes_weight' is no longer supported.`);
}
if (settings['index.force_memory_term_dictionary']) {
throw new Error(`'index.force_memory_term_dictionary' is no longer supported.`);
}
if (settings['index.max_adjacency_matrix_filters']) {
throw new Error(
`'index.max_adjacency_matrix_filters' is no longer supported; use 'indices.query.bool.max_clause_count' as an alternative.`
);
}
return settings;
};
// Use `flow` to pipe the settings through each function.
const transformSettings = flow(removeUnsettableSettings);
const transformSettings = flow(removeUnsettableSettings, validateSettings);
const updateFixableMappings = (mappings: FlatSettings['mappings']) => {
// TODO: change type to _doc
return mappings;
};

View file

@ -89,24 +89,6 @@ describe('ReindexActions', () => {
});
});
// in v5.6, the upgrade assistant appended to the index name instead of prepending
it(`prepends reindexed-v${currentMajor}- and removes reindex appended in v5`, async () => {
const indexName = 'myIndex-reindexed-v5';
await actions.createReindexOp(indexName);
expect(client.create).toHaveBeenCalledWith(REINDEX_OP_TYPE, {
indexName,
newIndexName: `reindexed-v${currentMajor}-myIndex`,
reindexOptions: undefined,
status: ReindexStatus.inProgress,
lastCompletedStep: ReindexStep.created,
locked: null,
reindexTaskId: null,
reindexTaskPercComplete: null,
errorMessage: null,
runningReindexCount: null,
});
});
it(`replaces reindexed-v${prevMajor} with reindexed-v${currentMajor}`, async () => {
await actions.createReindexOp(`reindexed-v${prevMajor}-myIndex`);
expect(client.create).toHaveBeenCalledWith(REINDEX_OP_TYPE, {

View file

@ -89,7 +89,7 @@ describe('reindex API', () => {
mockReindexService.findReindexOperation.mockResolvedValueOnce({
attributes: { indexName: 'wowIndex', status: ReindexStatus.inProgress },
});
mockReindexService.detectReindexWarnings.mockResolvedValueOnce([ReindexWarning.allField]);
mockReindexService.detectReindexWarnings.mockResolvedValueOnce([ReindexWarning.apmReindex]);
const resp = await routeDependencies.router.getHandler({
method: 'get',