Skip to content

Commit 6fbe134

Browse files
[9.0] [UII] Remove system-managed properties (dates) when updating index templates (#231524) (#232159)
# Backport This will backport the following commits from `main` to `9.0`: - [[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 02d0bd6 commit 6fbe134

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
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
@@ -749,6 +749,13 @@ export interface IndexTemplate {
749749
composed_of: string[];
750750
ignore_missing_component_templates?: string[];
751751
_meta: object;
752+
753+
// These properties are returned on ES read operations and
754+
// not allowed to be set on ES write operations
755+
created_date?: number;
756+
created_date_millis?: number;
757+
modified_date?: number;
758+
modified_date_millis?: number;
752759
}
753760

754761
export interface ESAssetMetadata {

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

Lines changed: 11 additions & 3 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 = {
@@ -220,7 +229,6 @@ export async function handleExperimentalDatastreamFeatureOptIn({
220229

221230
await esClient.indices.putIndexTemplate({
222231
name: featureMapEntry.data_stream,
223-
// @ts-expect-error
224232
body: indexTemplateBody,
225233
_meta: {
226234
has_experimental_data_stream_indexing_features: featureMapEntry.features.tsdb,

0 commit comments

Comments
 (0)