Skip to content

Commit

Permalink
[8.17] [Index Management] Fix schema for index templates (#203552) (#…
Browse files Browse the repository at this point in the history
…203724)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Index Management] Fix schema for index templates
(#203552)](#203552)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-11T09:06:46Z","message":"[Index
Management] Fix schema for index templates (#203552)\n\nFixes
https://github.com/elastic/kibana/issues/203553\r\n\r\n##
Summary\r\n\r\nThis PR fixes the template schema so that the server
allows creating a\r\ntemplate with undefined index mode. The issue is
that when we exposed\r\nthe index mode info in
#197874, we\r\nassumed that, by
default, the index mode is `standard` so `indexMode`\r\nwas added as a
required field. However,
in\r\nhttps://github.com//pull/199521, we added the index
mode\r\nfield only if data streams toggle is enabled, so the `indexMode`
is\r\n`undefined`.\r\n\r\nThe PR also fixes a smaller issuer where Index
mode is displayed even\r\nwhen it is undefined (when data streams are
disabled):\r\n**Before:**\r\n<img width=\"905\" alt=\"Screenshot
2024-12-10 at 19 01
09\"\r\nsrc=\"https://github.com/user-attachments/assets/e22cab14-eade-4591-8da8-f9aec5ad6c43\">\r\n\r\n**Now:**\r\n<img
width=\"905\" alt=\"Screenshot 2024-12-10 at 18 19
29\"\r\nsrc=\"https://github.com/user-attachments/assets/e7768cdc-9610-4a25-b403-0320b7137db5\">\r\n\r\n\r\n**How
to test:**\r\n1. Go to Index Management -> Index templates and start
creating an index\r\ntemplate.\r\n2. Specify the name and the index
pattern and disable the \"Data streams\"\r\ntoggle.\r\n3. Go to Review
step and verify that index mode is not displayed in the\r\nsummary and
that creating the index template is
successful.","sha":"bdc80322b08a99c763142b93e07179bed431f4dd","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index
Management","Team:Kibana
Management","release_note:skip","v9.0.0","backport:prev-minor","v8.17.0","v8.18.0","v8.17.1"],"title":"[Index
Management] Fix schema for index
templates","number":203552,"url":"https://github.com/elastic/kibana/pull/203552","mergeCommit":{"message":"[Index
Management] Fix schema for index templates (#203552)\n\nFixes
https://github.com/elastic/kibana/issues/203553\r\n\r\n##
Summary\r\n\r\nThis PR fixes the template schema so that the server
allows creating a\r\ntemplate with undefined index mode. The issue is
that when we exposed\r\nthe index mode info in
#197874, we\r\nassumed that, by
default, the index mode is `standard` so `indexMode`\r\nwas added as a
required field. However,
in\r\nhttps://github.com//pull/199521, we added the index
mode\r\nfield only if data streams toggle is enabled, so the `indexMode`
is\r\n`undefined`.\r\n\r\nThe PR also fixes a smaller issuer where Index
mode is displayed even\r\nwhen it is undefined (when data streams are
disabled):\r\n**Before:**\r\n<img width=\"905\" alt=\"Screenshot
2024-12-10 at 19 01
09\"\r\nsrc=\"https://github.com/user-attachments/assets/e22cab14-eade-4591-8da8-f9aec5ad6c43\">\r\n\r\n**Now:**\r\n<img
width=\"905\" alt=\"Screenshot 2024-12-10 at 18 19
29\"\r\nsrc=\"https://github.com/user-attachments/assets/e7768cdc-9610-4a25-b403-0320b7137db5\">\r\n\r\n\r\n**How
to test:**\r\n1. Go to Index Management -> Index templates and start
creating an index\r\ntemplate.\r\n2. Specify the name and the index
pattern and disable the \"Data streams\"\r\ntoggle.\r\n3. Go to Review
step and verify that index mode is not displayed in the\r\nsummary and
that creating the index template is
successful.","sha":"bdc80322b08a99c763142b93e07179bed431f4dd"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203552","number":203552,"mergeCommit":{"message":"[Index
Management] Fix schema for index templates (#203552)\n\nFixes
https://github.com/elastic/kibana/issues/203553\r\n\r\n##
Summary\r\n\r\nThis PR fixes the template schema so that the server
allows creating a\r\ntemplate with undefined index mode. The issue is
that when we exposed\r\nthe index mode info in
#197874, we\r\nassumed that, by
default, the index mode is `standard` so `indexMode`\r\nwas added as a
required field. However,
in\r\nhttps://github.com//pull/199521, we added the index
mode\r\nfield only if data streams toggle is enabled, so the `indexMode`
is\r\n`undefined`.\r\n\r\nThe PR also fixes a smaller issuer where Index
mode is displayed even\r\nwhen it is undefined (when data streams are
disabled):\r\n**Before:**\r\n<img width=\"905\" alt=\"Screenshot
2024-12-10 at 19 01
09\"\r\nsrc=\"https://github.com/user-attachments/assets/e22cab14-eade-4591-8da8-f9aec5ad6c43\">\r\n\r\n**Now:**\r\n<img
width=\"905\" alt=\"Screenshot 2024-12-10 at 18 19
29\"\r\nsrc=\"https://github.com/user-attachments/assets/e7768cdc-9610-4a25-b403-0320b7137db5\">\r\n\r\n\r\n**How
to test:**\r\n1. Go to Index Management -> Index templates and start
creating an index\r\ntemplate.\r\n2. Specify the name and the index
pattern and disable the \"Data streams\"\r\ntoggle.\r\n3. Go to Review
step and verify that index mode is not displayed in the\r\nsummary and
that creating the index template is
successful.","sha":"bdc80322b08a99c763142b93e07179bed431f4dd"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <[email protected]>
  • Loading branch information
kibanamachine and ElenaStoeva authored Dec 11, 2024
1 parent 0a840f0 commit 9ff0325
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/index_management/common/types/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface TemplateDeserialized {
priority?: number; // Composable template only
allowAutoCreate: string;
order?: number; // Legacy template only
indexMode: IndexMode;
indexMode?: IndexMode;
ilmPolicy?: {
name: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,19 @@ export const StepReview: React.FunctionComponent<Props> = React.memo(
</EuiDescriptionListDescription>

{/* Index mode */}
<EuiDescriptionListTitle data-test-subj="indexModeTitle">
<FormattedMessage
id="xpack.idxMgmt.templateForm.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="indexModeValue">
{indexModeLabels[indexMode]}
</EuiDescriptionListDescription>
{indexMode && (
<>
<EuiDescriptionListTitle data-test-subj="indexModeTitle">
<FormattedMessage
id="xpack.idxMgmt.templateForm.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription data-test-subj="indexModeValue">
{indexModeLabels[indexMode]}
</EuiDescriptionListDescription>
</>
)}

{/* Mappings */}
<EuiDescriptionListTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,19 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
)}

{/* Index mode */}
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.idxMgmt.templateDetails.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{indexModeLabels[indexMode]}
</EuiDescriptionListDescription>
{indexMode && (
<>
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.idxMgmt.templateDetails.stepReview.summaryTab.indexModeLabel"
defaultMessage="Index mode"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{indexModeLabels[indexMode]}
</EuiDescriptionListDescription>
</>
)}

{/* Allow auto create */}
{isLegacy !== true &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const templateSchema = schema.object({
version: schema.maybe(schema.number()),
order: schema.maybe(schema.number()),
priority: schema.maybe(schema.number()),
indexMode: schema.string(),
indexMode: schema.maybe(schema.string()),
// Not present for legacy templates
allowAutoCreate: schema.maybe(schema.string()),
template: schema.maybe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function templatesHelpers(getService: FtrProviderContext['getService']) {
name,
indexPatterns,
version: 1,
indexMode: 'standard',
template: { ...getTemplateMock(isMappingsSourceFieldEnabled) },
_kbnMeta: {
isLegacy,
Expand Down

0 comments on commit 9ff0325

Please sign in to comment.