Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UA] Remove 7->8 multitype check #203995

Merged
merged 6 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a sustainable re-architecture PR that merged recently reset some these to management 🙈

Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ x-pack/test/api_integration/apis/management/index_management/inference_endpoints
/x-pack/test/stack_functional_integration/apps/ccs @elastic/kibana-management
/x-pack/test/functional/services/data_stream.ts @elastic/kibana-management
/x-pack/test/functional/page_objects/watcher_page.ts @elastic/kibana-management
/x-pack/test/functional/page_objects/upgrade_assistant_page.ts @elastic/kibana-management
/x-pack/test/functional/page_objects/upgrade_assistant_page.ts @elastic/kibana-core
/x-pack/test/functional/page_objects/snapshot_restore_page.ts @elastic/kibana-management
/x-pack/test/functional/page_objects/rollup_page.ts @elastic/kibana-management
/x-pack/test/functional/page_objects/ingest_pipelines_page.ts @elastic/kibana-management
Expand All @@ -2042,7 +2042,7 @@ x-pack/test/api_integration/apis/management/index_management/inference_endpoints
/x-pack/test/functional/apps/upgrade_assistant @elastic/kibana-core
/x-pack/test/functional/apps/dev_tools @elastic/kibana-management
/test/plugin_functional/test_suites/management @elastic/kibana-management
/x-pack/test/upgrade_assistant_integration @elastic/kibana-management
/x-pack/test/upgrade_assistant_integration @elastic/kibana-core
/test/plugin_functional/plugins/management_test_plugin @elastic/kibana-management
/test/functional/page_objects/management/*.ts @elastic/kibana-management
/test/functional/page_objects/embedded_console.ts @elastic/kibana-management
Expand Down Expand Up @@ -3243,7 +3243,7 @@ x-pack/platform/plugins/private/snapshot_restore @elastic/kibana-management
x-pack/platform/plugins/private/telemetry_collection_xpack @elastic/kibana-core
x-pack/platform/plugins/private/transform @elastic/ml-ui
x-pack/platform/plugins/private/translations @elastic/kibana-localization
x-pack/platform/plugins/private/upgrade_assistant @elastic/kibana-management
x-pack/platform/plugins/private/upgrade_assistant @elastic/kibana-core
x-pack/platform/plugins/private/watcher @elastic/kibana-management
x-pack/platform/plugins/shared/actions @elastic/response-ops
x-pack/platform/plugins/shared/ai_infra/llm_tasks @elastic/appex-ai-infra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48401,8 +48401,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.flyoutHeader": "Réindexer {index}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.learnMoreLinkLabel": "En savoir plus",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.acceptChangesTitle": "Accepter les modifications",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail": "Les types de mapping ne sont plus pris en charge dans Elastic 8.x. Assurez-vous qu'aucun code d'application ou script n'utilise {mappingType}.",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle": "Remplacer le type de mapping {mappingType} par {defaultType}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningDetail": "Les paramètres d'index déclassés ont été détectés :",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningTitle": "Retirer les paramètres d'index déclassés",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "Sauvegardez l'index avant de continuer. Pour poursuivre avec la réindexation, acceptez chaque modification.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48248,8 +48248,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.flyoutHeader": "再インデックス{index}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.learnMoreLinkLabel": "詳細",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.acceptChangesTitle": "変更を承諾",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail": "マッピングタイプはElastic 8.xではサポートされていません。アプリケーションコードまたはスクリプトが{mappingType}に依存していないことを確認してください。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle": "マッピングタイプ{mappingType}を{defaultType}で置き換えます",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningDetail": "次の廃止予定のインデックス設定が検出されました。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningTitle": "廃止予定のインデックス設定を削除",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "続行する前に、インデックスをバックアップしてください。再インデックスを続行するには、各変更を承諾してください。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47537,8 +47537,6 @@
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.flyoutHeader": "重新索引 {index}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.learnMoreLinkLabel": "了解详情",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.acceptChangesTitle": "接受更改",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail": "映射类型在 Elastic 8.x 中不再受支持。确保没有应用程序代码或脚本依赖 {mappingType}。",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle": "将映射类型 {mappingType} 替换为 {defaultType}",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningDetail": "检测到以下弃用的索引设置:",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.deprecatedIndexSettingsWarningTitle": "移除弃用的索引设置",
"xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.destructiveCallout.calloutDetail": "继续前备份索引。要继续重新索引,请接受每个更改。",
Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/upgrade_assistant/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,15 @@ export interface ReindexOperation {

export type ReindexSavedObject = SavedObject<ReindexOperation>;

// 7.0 -> 8.0 warnings
export type ReindexWarningTypes = 'customTypeName' | 'indexSetting' | 'replaceIndexWithAlias';
// 8.0 -> 9.0 warnings
export type ReindexWarningTypes = 'indexSetting' | 'replaceIndexWithAlias';

export interface ReindexWarning {
warningType: ReindexWarningTypes;
/**
* Optional metadata for deprecations
*
* @remark
* For example, for the "customTypeName" deprecation,
* we want to surface the typeName to the user.
* For "indexSetting" we want to surface the deprecated settings.
*/
meta?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ describe('WarningsFlyoutStep', () => {
const defaultPropsWithWarnings = {
...defaultProps,
warnings: [
{
warningType: 'customTypeName',
meta: {
typeName: 'my_mapping_type',
},
},
{
warningType: 'indexSetting',
meta: {
Expand All @@ -76,9 +70,7 @@ describe('WarningsFlyoutStep', () => {
button.simulate('click');
expect(defaultPropsWithWarnings.continueReindex).not.toHaveBeenCalled();

// first warning (customTypeName)
wrapper.find(`input#${idForWarning(0)}`).simulate('change');
// second warning (indexSetting)
// first warning (indexSetting)
wrapper.find(`input#${idForWarning(1)}`).simulate('change');
button.simulate('click');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,42 +82,6 @@ export interface WarningCheckboxProps {
meta?: ReindexWarning['meta'];
}

export const CustomTypeNameWarningCheckbox: React.FunctionComponent<WarningCheckboxProps> = ({
isChecked,
onChange,
docLinks,
id,
meta,
}) => {
return (
<WarningCheckbox
isChecked={isChecked}
onChange={onChange}
warningId={id}
label={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningTitle"
defaultMessage="Replace mapping type {mappingType} with {defaultType}"
values={{
mappingType: <EuiCode>{meta!.typeName as string}</EuiCode>,
defaultType: <EuiCode>_doc</EuiCode>,
}}
/>
}
description={
<FormattedMessage
id="xpack.upgradeAssistant.checkupTab.reindexing.flyout.warningsStep.customTypeNameWarningDetail"
defaultMessage="Mapping types are no longer supported in Elastic 8.x. Ensure no application code or scripts rely on {mappingType}."
values={{
mappingType: <EuiCode>{meta!.typeName as string}</EuiCode>,
}}
/>
}
documentationUrl={docLinks.elasticsearch.typesRemoval}
/>
);
};

export const DeprecatedSettingWarningCheckbox: React.FunctionComponent<WarningCheckboxProps> = ({
isChecked,
onChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from '../../../../../../../common/types';
import { useAppContext } from '../../../../../app_context';
import {
CustomTypeNameWarningCheckbox,
DeprecatedSettingWarningCheckbox,
ReplaceIndexWithAliasWarningCheckbox,
WarningCheckboxProps,
Expand All @@ -40,7 +39,6 @@ interface CheckedIds {
const warningToComponentMap: {
[key in ReindexWarningTypes]: React.FunctionComponent<WarningCheckboxProps>;
} = {
customTypeName: CustomTypeNameWarningCheckbox,
indexSetting: DeprecatedSettingWarningCheckbox,
replaceIndexWithAlias: ReplaceIndexWithAliasWarningCheckbox,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,71 +182,5 @@ describe('transformFlatSettings', () => {
})
).toEqual([]);
});

if (currentMajor === 7) {
describe('[7.x] customTypeName warning', () => {
it('returns customTypeName warning for non-_doc mapping types', () => {
expect(
getReindexWarnings({
settings: {},
mappings: { doc: {} },
})
).toEqual([
{
warningType: 'customTypeName',
meta: {
typeName: 'doc',
},
},
]);
});
it('does not return customTypeName warning for _doc mapping types', () => {
expect(
getReindexWarnings({
settings: {},
mappings: { _doc: {} },
})
).toEqual([]);
});
});

describe('[7.x] deprecatedSetting warning', () => {
it('returns deprecatedSetting warning for deprecated index settings', () => {
expect(
getReindexWarnings({
settings: {
// Deprecated settings
'index.force_memory_term_dictionary': '1024',
'index.max_adjacency_matrix_filters': 'true',
'index.soft_deletes.enabled': 'true',
},
mappings: {},
})
).toEqual([
{
warningType: 'indexSetting',
meta: {
deprecatedSettings: [
'index.force_memory_term_dictionary',
'index.max_adjacency_matrix_filters',
'index.soft_deletes.enabled',
],
},
},
]);
});

it('does not return a deprecatedSetting warning for there are no deprecated index settings', () => {
expect(
getReindexWarnings({
settings: {
'index.number_of_replicas': '1',
},
mappings: {},
})
).toEqual([]);
});
});
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { flow, omit } from 'lodash';
import { ReindexWarning } from '../../../common/types';
import { versionService } from '../version';
import { FlatSettings, FlatSettingsWithTypeName } from './types';
import { FlatSettings } from './types';
export interface ParsedIndexName {
cleanIndexName: string;
baseName: string;
Expand Down Expand Up @@ -75,27 +75,8 @@ export const generateNewIndexName = (indexName: string): string => {
: `${currentVersion}-${sourceName}`;
};

export const getCustomTypeWarning = (
flatSettings: FlatSettingsWithTypeName | FlatSettings
): ReindexWarning | undefined => {
const DEFAULT_TYPE_NAME = '_doc';
// In 7+, it's not possible to have more than one type,
// so always grab the first (and only) key.
const typeName = Object.getOwnPropertyNames(flatSettings.mappings)[0];
const typeNameWarning = Boolean(typeName && typeName !== DEFAULT_TYPE_NAME);

if (typeNameWarning) {
return {
warningType: 'customTypeName',
meta: {
typeName,
},
};
}
};

export const getDeprecatedSettingWarning = (
flatSettings: FlatSettingsWithTypeName | FlatSettings
flatSettings: FlatSettings
): ReindexWarning | undefined => {
const { settings } = flatSettings;

Expand Down Expand Up @@ -131,19 +112,12 @@ export const getDeprecatedSettingWarning = (
* Returns an array of warnings that should be displayed to user before reindexing begins.
* @param flatSettings
*/
export const getReindexWarnings = (
flatSettings: FlatSettingsWithTypeName | FlatSettings
): ReindexWarning[] => {
export const getReindexWarnings = (flatSettings: FlatSettings): ReindexWarning[] => {
const warnings = [] as ReindexWarning[];

if (versionService.getMajorVersion() === 7) {
const customTypeWarning = getCustomTypeWarning(flatSettings);
if (versionService.getMajorVersion() === 8) {
const deprecatedSettingWarning = getDeprecatedSettingWarning(flatSettings);

if (customTypeWarning) {
warnings.push(customTypeWarning);
}

if (deprecatedSettingWarning) {
warnings.push(deprecatedSettingWarning);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import {
ReindexStatus,
ReindexStep,
} from '../../../common/types';
import { versionService } from '../version';
import { generateNewIndexName } from './index_settings';
import { FlatSettings, FlatSettingsWithTypeName } from './types';
import { FlatSettings } from './types';

// TODO: base on elasticsearch.requestTimeout?
export const LOCK_WINDOW = moment.duration(90, 'seconds');
Expand Down Expand Up @@ -80,10 +79,7 @@ export interface ReindexActions {
* Retrieve index settings (in flat, dot-notation style) and mappings.
* @param indexName
*/
getFlatSettings(
indexName: string,
withTypeName?: boolean
): Promise<FlatSettings | FlatSettingsWithTypeName | null>;
getFlatSettings(indexName: string): Promise<FlatSettings | null>;
}

export const reindexActionsFactory = (
Expand Down Expand Up @@ -208,23 +204,10 @@ export const reindexActionsFactory = (
},

async getFlatSettings(indexName: string) {
let flatSettings;

if (versionService.getMajorVersion() === 7) {
// On 7.x, we need to get index settings with mapping type
flatSettings = await esClient.indices.get({
index: indexName,
flat_settings: true,
// This @ts-ignore is needed on master since the flag is deprecated on >7.x
// @ts-ignore
include_type_name: true,
});
} else {
flatSettings = await esClient.indices.get({
index: indexName,
flat_settings: true,
});
}
const flatSettings = await esClient.indices.get({
index: indexName,
flat_settings: true,
});

if (!flatSettings[indexName]) {
return null;
Expand Down
11 changes: 0 additions & 11 deletions x-pack/plugins/upgrade_assistant/server/lib/reindexing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,3 @@ export interface FlatSettings {
_meta?: MetaProperties;
};
}

// Specific to 7.x-8 upgrade
export interface FlatSettingsWithTypeName {
settings: estypes.IndicesIndexState['settings'];
mappings?: {
[typeName: string]: {
properties?: MappingProperties;
_meta?: MetaProperties;
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ describe('reindex API', () => {
});
mockReindexService.detectReindexWarnings.mockResolvedValueOnce([
{
warningType: 'customTypeName',
warningType: 'indexSetting',
meta: {
typeName: 'my_mapping_type',
settingA: 'deprecated',
},
},
]);
Expand All @@ -120,9 +120,9 @@ describe('reindex API', () => {
expect(data.reindexOp).toEqual({ indexName: 'wowIndex', status: ReindexStatus.inProgress });
expect(data.warnings).toEqual([
{
warningType: 'customTypeName',
warningType: 'indexSetting',
meta: {
typeName: 'my_mapping_type',
settingA: 'deprecated',
},
},
]);
Expand Down
Loading