From 950525c79de5ae8fc1ed78585c48cd33a6466d1b Mon Sep 17 00:00:00 2001 From: MichelLosier Date: Tue, 12 Aug 2025 09:51:07 -0700 Subject: [PATCH 1/6] Undeprecate LegacyStackTemplateRegistry --- .../elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java index c89a8237d40b7..fa03c395b761a 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java @@ -34,7 +34,6 @@ import static org.elasticsearch.xpack.stack.StackTemplateRegistry.STACK_TEMPLATES_ENABLED; -@Deprecated(since = "8.12.0", forRemoval = true) public class LegacyStackTemplateRegistry extends IndexTemplateRegistry { private static final Logger logger = LogManager.getLogger(LegacyStackTemplateRegistry.class); @@ -47,7 +46,7 @@ public class LegacyStackTemplateRegistry extends IndexTemplateRegistry { private final ClusterService clusterService; private volatile boolean stackTemplateEnabled; - private static final Map ADDITIONAL_TEMPLATE_VARIABLES = Map.of("xpack.stack.template.deprecated", "true"); + private static final Map ADDITIONAL_TEMPLATE_VARIABLES = Map.of("xpack.stack.template.deprecated", "false"); // General mappings conventions for any data that ends up in a data stream public static final String DATA_STREAMS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "data-streams-mappings"; From 438cff45da7802dc837234ad0e3f9e419d9fb6ad Mon Sep 17 00:00:00 2001 From: MichelLosier Date: Tue, 12 Aug 2025 11:13:01 -0700 Subject: [PATCH 2/6] Update LegacyStackTemplateRegistry tests to assert false on deprecation check --- .../xpack/stack/LegacyStackTemplateRegistryTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java index 654cf494e0e6f..728cbe2f05773 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java @@ -43,15 +43,15 @@ public void tearDown() throws Exception { threadPool.shutdownNow(); } - public void testThatTemplatesAreDeprecated() { + public void testThatTemplatesAreNotDeprecated() { for (ComposableIndexTemplate it : registry.getComposableTemplateConfigs().values()) { - assertTrue(it.isDeprecated()); + assertFalse(it.isDeprecated()); } for (LifecyclePolicy ilm : registry.getLifecyclePolicies()) { - assertTrue(ilm.isDeprecated()); + assertFalse(ilm.isDeprecated()); } for (ComponentTemplate ct : registry.getComponentTemplateConfigs().values()) { - assertTrue(ct.deprecated()); + assertFalse(ct.deprecated()); } registry.getIngestPipelines() .stream() From 2e9560223ef91ec48d64701b76a7167b97f6774c Mon Sep 17 00:00:00 2001 From: MichelLosier Date: Tue, 12 Aug 2025 11:19:17 -0700 Subject: [PATCH 3/6] Fix legacy ingest pipelines test --- .../xpack/stack/LegacyStackTemplateRegistryTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java index 728cbe2f05773..c358d5f0ba213 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java @@ -57,7 +57,7 @@ public void testThatTemplatesAreNotDeprecated() { .stream() .map(ipc -> new PipelineConfiguration(ipc.getId(), ipc.loadConfig(), XContentType.JSON)) .map(PipelineConfiguration::getConfig) - .forEach(p -> assertTrue((Boolean) p.get("deprecated"))); + .forEach(p -> assertFalse((Boolean) p.get("deprecated"))); } } From 9eb5513ac6129af4fdeb50bce64dbb95eaeb60cf Mon Sep 17 00:00:00 2001 From: Michel Losier Date: Tue, 12 Aug 2025 11:52:15 -0700 Subject: [PATCH 4/6] Update docs/changelog/132764.yaml --- docs/changelog/132764.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/132764.yaml diff --git a/docs/changelog/132764.yaml b/docs/changelog/132764.yaml new file mode 100644 index 0000000000000..432ab13d1a42f --- /dev/null +++ b/docs/changelog/132764.yaml @@ -0,0 +1,5 @@ +pr: 132764 +summary: Undeprecate `LegacyStackTemplateRegistry` +area: Indices APIs +type: enhancement +issues: [] From 49ae9ccc8d3f4e01be18237710c25aa3d92084e6 Mon Sep 17 00:00:00 2001 From: MichelLosier Date: Wed, 13 Aug 2025 07:53:24 -0700 Subject: [PATCH 5/6] Undeprecate metrics, logs, and synthetics legacy ILM policies --- .../xpack/stack/LegacyStackTemplateRegistry.java | 8 +------- .../xpack/stack/StackTemplateRegistry.java | 6 ++++++ .../stack/LegacyStackTemplateRegistryTests.java | 10 +++++----- .../xpack/stack/StackTemplateRegistryTests.java | 12 ++++++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java index fa03c395b761a..e8c29a2de445b 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistry.java @@ -46,7 +46,7 @@ public class LegacyStackTemplateRegistry extends IndexTemplateRegistry { private final ClusterService clusterService; private volatile boolean stackTemplateEnabled; - private static final Map ADDITIONAL_TEMPLATE_VARIABLES = Map.of("xpack.stack.template.deprecated", "false"); + private static final Map ADDITIONAL_TEMPLATE_VARIABLES = Map.of("xpack.stack.template.deprecated", "true"); // General mappings conventions for any data that ends up in a data stream public static final String DATA_STREAMS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "data-streams-mappings"; @@ -68,7 +68,6 @@ public class LegacyStackTemplateRegistry extends IndexTemplateRegistry { ////////////////////////////////////////////////////////// public static final String LOGS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "logs-mappings"; public static final String LOGS_SETTINGS_COMPONENT_TEMPLATE_NAME = "logs-settings"; - public static final String LOGS_ILM_POLICY_NAME = "logs"; ////////////////////////////////////////////////////////// // Metrics components (for matching metric-*-* indices) @@ -76,14 +75,12 @@ public class LegacyStackTemplateRegistry extends IndexTemplateRegistry { public static final String METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "metrics-mappings"; public static final String METRICS_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics-settings"; public static final String METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics-tsdb-settings"; - public static final String METRICS_ILM_POLICY_NAME = "metrics"; ////////////////////////////////////////////////////////// // Synthetics components (for matching synthetics-*-* indices) ////////////////////////////////////////////////////////// public static final String SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "synthetics-mappings"; public static final String SYNTHETICS_SETTINGS_COMPONENT_TEMPLATE_NAME = "synthetics-settings"; - public static final String SYNTHETICS_ILM_POLICY_NAME = "synthetics"; public LegacyStackTemplateRegistry( Settings nodeSettings, @@ -117,9 +114,6 @@ private void updateEnabledSetting(boolean newValue) { } private static final List LIFECYCLE_POLICY_CONFIGS = List.of( - new LifecyclePolicyConfig(LOGS_ILM_POLICY_NAME, "/logs@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), - new LifecyclePolicyConfig(METRICS_ILM_POLICY_NAME, "/metrics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), - new LifecyclePolicyConfig(SYNTHETICS_ILM_POLICY_NAME, "/synthetics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(ILM_7_DAYS_POLICY_NAME, "/7-days@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(ILM_30_DAYS_POLICY_NAME, "/30-days@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(ILM_90_DAYS_POLICY_NAME, "/90-days@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), diff --git a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java index bd1178937b463..2837eb4bf2897 100644 --- a/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java +++ b/x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java @@ -73,6 +73,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { ////////////////////////////////////////////////////////// public static final String LOGS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "logs@mappings"; public static final String LOGS_SETTINGS_COMPONENT_TEMPLATE_NAME = "logs@settings"; + public static final String LEGACY_LOGS_ILM_POLICY_NAME = "logs"; public static final String LOGS_ILM_POLICY_NAME = "logs@lifecycle"; public static final String LOGS_INDEX_TEMPLATE_NAME = "logs"; @@ -82,6 +83,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { public static final String METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "metrics@mappings"; public static final String METRICS_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics@settings"; public static final String METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics@tsdb-settings"; + public static final String LEGACY_METRICS_ILM_POLICY_NAME = "metrics"; public static final String METRICS_ILM_POLICY_NAME = "metrics@lifecycle"; public static final String METRICS_INDEX_TEMPLATE_NAME = "metrics"; @@ -97,6 +99,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry { ////////////////////////////////////////////////////////// public static final String SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "synthetics@mappings"; public static final String SYNTHETICS_SETTINGS_COMPONENT_TEMPLATE_NAME = "synthetics@settings"; + public static final String LEGACY_SYNTHETICS_ILM_POLICY_NAME = "synthetics"; public static final String SYNTHETICS_ILM_POLICY_NAME = "synthetics@lifecycle"; public static final String SYNTHETICS_INDEX_TEMPLATE_NAME = "synthetics"; @@ -260,8 +263,11 @@ private void updateEnabledSetting(boolean newValue) { } private static final List LIFECYCLE_POLICY_CONFIGS = List.of( + new LifecyclePolicyConfig(LEGACY_LOGS_ILM_POLICY_NAME, "/logs@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(LOGS_ILM_POLICY_NAME, "/logs@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), + new LifecyclePolicyConfig(LEGACY_METRICS_ILM_POLICY_NAME, "/metrics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(METRICS_ILM_POLICY_NAME, "/metrics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), + new LifecyclePolicyConfig(LEGACY_SYNTHETICS_ILM_POLICY_NAME, "/synthetics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(SYNTHETICS_ILM_POLICY_NAME, "/synthetics@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(TRACES_ILM_POLICY_NAME, "/traces@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), new LifecyclePolicyConfig(ILM_7_DAYS_POLICY_NAME, "/7-days@lifecycle.json", ADDITIONAL_TEMPLATE_VARIABLES), diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java index c358d5f0ba213..654cf494e0e6f 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/LegacyStackTemplateRegistryTests.java @@ -43,21 +43,21 @@ public void tearDown() throws Exception { threadPool.shutdownNow(); } - public void testThatTemplatesAreNotDeprecated() { + public void testThatTemplatesAreDeprecated() { for (ComposableIndexTemplate it : registry.getComposableTemplateConfigs().values()) { - assertFalse(it.isDeprecated()); + assertTrue(it.isDeprecated()); } for (LifecyclePolicy ilm : registry.getLifecyclePolicies()) { - assertFalse(ilm.isDeprecated()); + assertTrue(ilm.isDeprecated()); } for (ComponentTemplate ct : registry.getComponentTemplateConfigs().values()) { - assertFalse(ct.deprecated()); + assertTrue(ct.deprecated()); } registry.getIngestPipelines() .stream() .map(ipc -> new PipelineConfiguration(ipc.getId(), ipc.loadConfig(), XContentType.JSON)) .map(PipelineConfiguration::getConfig) - .forEach(p -> assertFalse((Boolean) p.get("deprecated"))); + .forEach(p -> assertTrue((Boolean) p.get("deprecated"))); } } diff --git a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java index 970ba67e25667..be2d50f43d818 100644 --- a/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java +++ b/x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java @@ -131,7 +131,8 @@ public void testDisabledStillAddsComponentTemplatesAndIlmPolicies() { assertThat( // We have a naming convention that internal ILM policies contain `@`. See also put-lifecycle.asciidoc. disabledRegistry.getLifecyclePolicies().stream().filter(p -> p.getName().contains("@") == false).collect(Collectors.toSet()), - empty() + // 3 duplicate legacy ILM policies do not follow this convention: metrics, logs, synthetics + hasSize(3) ); } @@ -173,8 +174,11 @@ public void testThatNonExistingPoliciesAreAddedImmediately() throws Exception { assertThat( putRequest.getPolicy().getName(), anyOf( + equalTo(StackTemplateRegistry.LEGACY_LOGS_ILM_POLICY_NAME), equalTo(StackTemplateRegistry.LOGS_ILM_POLICY_NAME), + equalTo(StackTemplateRegistry.LEGACY_METRICS_ILM_POLICY_NAME), equalTo(StackTemplateRegistry.METRICS_ILM_POLICY_NAME), + equalTo(StackTemplateRegistry.LEGACY_SYNTHETICS_ILM_POLICY_NAME), equalTo(StackTemplateRegistry.SYNTHETICS_ILM_POLICY_NAME), equalTo(StackTemplateRegistry.TRACES_ILM_POLICY_NAME), equalTo(StackTemplateRegistry.ILM_7_DAYS_POLICY_NAME), @@ -200,7 +204,7 @@ public void testThatNonExistingPoliciesAreAddedImmediately() throws Exception { ClusterChangedEvent event = createClusterChangedEvent(Collections.emptyMap(), nodes); registry.clusterChanged(event); - assertBusy(() -> assertThat(calledTimes.get(), equalTo(9))); + assertBusy(() -> assertThat(calledTimes.get(), equalTo(12))); } public void testPolicyAlreadyExists() { @@ -209,7 +213,7 @@ public void testPolicyAlreadyExists() { Map policyMap = new HashMap<>(); List policies = registry.getLifecyclePolicies(); - assertThat(policies, hasSize(9)); + assertThat(policies, hasSize(12)); policies.forEach(p -> policyMap.put(p.getName(), p)); client.setVerifier((action, request, listener) -> { @@ -280,7 +284,7 @@ public void testPolicyAlreadyExistsButDiffers() throws IOException { Map policyMap = new HashMap<>(); String policyStr = "{\"phases\":{\"delete\":{\"min_age\":\"1m\",\"actions\":{\"delete\":{}}}}}"; List policies = registry.getLifecyclePolicies(); - assertThat(policies, hasSize(9)); + assertThat(policies, hasSize(12)); policies.forEach(p -> policyMap.put(p.getName(), p)); client.setVerifier((action, request, listener) -> { From ac4419bb7728c66c1f01bd5ff65b5bd74f0ff9b2 Mon Sep 17 00:00:00 2001 From: MichelLosier Date: Wed, 13 Aug 2025 08:41:30 -0700 Subject: [PATCH 6/6] Update changelog details --- docs/changelog/132764.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/132764.yaml b/docs/changelog/132764.yaml index 432ab13d1a42f..4b2313b3f681e 100644 --- a/docs/changelog/132764.yaml +++ b/docs/changelog/132764.yaml @@ -1,5 +1,5 @@ pr: 132764 -summary: Undeprecate `LegacyStackTemplateRegistry` +summary: Undeprecate metrics, logs, and synthetics legacy ILM policies area: Indices APIs type: enhancement issues: []