Skip to content

Commit 57e644a

Browse files
committed
[UII] Remove system-managed properties (dates) when updating index templates (elastic#231524)
## Summary Resolves elastic#230902. This PR removes system-managed properties (dates) from the retrieved index templates when updating the same index template (triggered when experimental datastream feature settings have been changed). The test that was failing is now re-enabled. Similar to elastic#231505, this is due to ES introducing these new date/timestamp fields in elastic/elasticsearch#131536. (cherry picked from commit 9cdbe77)
1 parent 1bcab40 commit 57e644a

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
@@ -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 & 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)