Skip to content

Commit 6700ec0

Browse files
[9.1] [UII] Remove system-managed properties (dates) when updating index templates (#231524) (#232160)
# Backport This will backport the following commits from `main` to `9.1`: - [[UII] Remove system-managed properties (dates) when updating index templates (#231524)](#231524) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Jen Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-13T19:23:04Z","message":"[UII] Remove system-managed properties (dates) when updating index templates (#231524)\n\n## Summary\n\nResolves #230902. This PR removes system-managed properties (dates) from\nthe retrieved index templates when updating the same index template\n(triggered when experimental datastream feature settings have been\nchanged). The test that was failing is now re-enabled.\n\nSimilar to #231505, this is due to\nES introducing these new date/timestamp fields in\nhttps://github.com/elastic/elasticsearch/pull/131536.","sha":"9cdbe77e42ef8985daaf719da7c9895c6a56444d","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.2.0","v9.1.3","v8.19.3","v9.0.6"],"title":"[UII] Remove system-managed properties (dates) when updating index templates","number":231524,"url":"https://github.com/elastic/kibana/pull/231524","mergeCommit":{"message":"[UII] Remove system-managed properties (dates) when updating index templates (#231524)\n\n## Summary\n\nResolves #230902. This PR removes system-managed properties (dates) from\nthe retrieved index templates when updating the same index template\n(triggered when experimental datastream feature settings have been\nchanged). The test that was failing is now re-enabled.\n\nSimilar to #231505, this is due to\nES introducing these new date/timestamp fields in\nhttps://github.com/elastic/elasticsearch/pull/131536.","sha":"9cdbe77e42ef8985daaf719da7c9895c6a56444d"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/231524","number":231524,"mergeCommit":{"message":"[UII] Remove system-managed properties (dates) when updating index templates (#231524)\n\n## Summary\n\nResolves #230902. This PR removes system-managed properties (dates) from\nthe retrieved index templates when updating the same index template\n(triggered when experimental datastream feature settings have been\nchanged). The test that was failing is now re-enabled.\n\nSimilar to #231505, this is due to\nES introducing these new date/timestamp fields in\nhttps://github.com/elastic/elasticsearch/pull/131536.","sha":"9cdbe77e42ef8985daaf719da7c9895c6a56444d"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Jen Huang <[email protected]>
1 parent 04077ba commit 6700ec0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

x-pack/platform/plugins/shared/fleet/common/types/models/epm.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,13 @@ export interface IndexTemplate {
763763
composed_of: string[];
764764
ignore_missing_component_templates?: string[];
765765
_meta: object;
766+
767+
// These properties are returned on ES read operations and
768+
// not allowed to be set on ES write operations
769+
created_date?: number;
770+
created_date_millis?: number;
771+
modified_date?: number;
772+
modified_date_millis?: number;
766773
}
767774

768775
export interface ESAssetMetadata {

x-pack/platform/plugins/shared/fleet/server/services/package_policies/experimental_datastream_features.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,17 @@ export async function handleExperimentalDatastreamFeatureOptIn({
199199
});
200200
}
201201

202-
const indexTemplate = indexTemplateRes.index_templates[0].index_template;
203-
let updatedIndexTemplate = indexTemplate as IndexTemplate;
202+
const rawIndexTemplate = indexTemplateRes.index_templates[0].index_template;
203+
204+
// Remove system-managed properties (dates) that cannot be set during create/update of index templates
205+
const {
206+
created_date: createdDate,
207+
created_date_millis: createdDateMillis,
208+
modified_date: modifiedDate,
209+
modified_date_millis: modifiedDateMillis,
210+
...indexTemplate
211+
} = rawIndexTemplate as IndexTemplate;
212+
let updatedIndexTemplate = indexTemplate;
204213

205214
if (isTSDBOptInChanged) {
206215
const indexTemplateBody = {

0 commit comments

Comments
 (0)