From a1f0b893e1132cfc29e2831d987dd8c38c9bc6ce Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 14:07:24 -0600 Subject: [PATCH 01/13] Retry ILM async action after reindexing data stream --- .../org/elasticsearch/TransportVersions.java | 4 + .../core/ilm/action/RetryActionRequest.java | 111 +++++++++++++++ .../core/security/user/InternalUsers.java | 4 +- .../xpack/ilm/action/RestRetryAction.java | 3 +- .../ilm/action/TransportRetryAction.java | 127 ++++-------------- .../xpack/ilm/action/RetryRequestTests.java | 23 ++-- ...indexDataStreamPersistentTaskExecutor.java | 17 ++- .../upgrades/DataStreamsUpgradeIT.java | 76 ++++++++--- 8 files changed, 239 insertions(+), 126 deletions(-) create mode 100644 x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 06e8d3177a4ca..183bad9e2d9af 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -177,6 +177,7 @@ static TransportVersion def(int id) { public static final TransportVersion INFERENCE_REQUEST_ADAPTIVE_RATE_LIMITING = def(8_839_0_00); public static final TransportVersion ML_INFERENCE_IBM_WATSONX_RERANK_ADDED = def(8_840_0_00); public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_18 = def(8_840_0_01); + public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18 = def(8_840_0_02); public static final TransportVersion INITIAL_ELASTICSEARCH_8_19 = def(8_841_0_00); public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_X = def(8_841_0_01); public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_19 = def(8_841_0_02); @@ -184,6 +185,7 @@ static TransportVersion def(int id) { public static final TransportVersion ESQL_SUPPORT_PARTIAL_RESULTS_BACKPORT_8_19 = def(8_841_0_04); public static final TransportVersion VOYAGE_AI_INTEGRATION_ADDED_BACKPORT_8_X = def(8_841_0_05); public static final TransportVersion JINA_AI_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_19 = def(8_841_0_06); + public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19 = def(8_841_0_07); public static final TransportVersion INITIAL_ELASTICSEARCH_9_0 = def(9_000_0_00); public static final TransportVersion REMOVE_SNAPSHOT_FAILURES_90 = def(9_000_0_01); public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED_90 = def(9_000_0_02); @@ -191,6 +193,7 @@ static TransportVersion def(int id) { public static final TransportVersion ESQL_DRIVER_TASK_DESCRIPTION_90 = def(9_000_0_04); public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_9_0 = def(9_000_0_05); public static final TransportVersion BYTE_SIZE_VALUE_ALWAYS_USES_BYTES_90 = def(9_000_0_06); + public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90 = def(9_000_0_07); public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED = def(9_001_0_00); public static final TransportVersion REMOVE_SNAPSHOT_FAILURES = def(9_002_0_00); public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED = def(9_003_0_00); @@ -211,6 +214,7 @@ static TransportVersion def(int id) { public static final TransportVersion MULTI_PROJECT = def(9_018_0_00); public static final TransportVersion STORED_SCRIPT_CONTENT_LENGTH = def(9_019_0_00); public static final TransportVersion JINA_AI_EMBEDDING_TYPE_SUPPORT_ADDED = def(9_020_0_00); + public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR = def(9_021_0_00); /* * STOP! READ THIS FIRST! No, really, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java new file mode 100644 index 0000000000000..78eab303667a4 --- /dev/null +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java @@ -0,0 +1,111 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.core.ilm.action; + +import org.elasticsearch.TransportVersions; +import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.IndicesRequest; +import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.action.support.master.AcknowledgedRequest; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.core.TimeValue; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Objects; + +public class RetryActionRequest extends AcknowledgedRequest implements IndicesRequest.Replaceable { + private String[] indices; + private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); + private boolean requireError = false; + + public RetryActionRequest(TimeValue masterNodeTimeout, TimeValue ackTimeout, String... indices) { + super(masterNodeTimeout, ackTimeout); + this.indices = indices; + } + + public RetryActionRequest(StreamInput in) throws IOException { + super(in); + this.indices = in.readStringArray(); + this.indicesOptions = IndicesOptions.readIndicesOptions(in); + if (in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR) + || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) + || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) + || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { + this.requireError = in.readBoolean(); + } + } + + @Override + public RetryActionRequest indices(String... indices) { + this.indices = indices; + return this; + } + + @Override + public String[] indices() { + return indices; + } + + @Override + public IndicesOptions indicesOptions() { + return indicesOptions; + } + + public RetryActionRequest indicesOptions(IndicesOptions indicesOptions) { + this.indicesOptions = indicesOptions; + return this; + } + + public void requireError(boolean requireError) { + this.requireError = requireError; + } + + public boolean requireError() { + return requireError; + } + + @Override + public ActionRequestValidationException validate() { + return null; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + out.writeStringArray(indices); + indicesOptions.writeIndicesOptions(out); + if (out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR) + || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) + || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) + || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { + out.writeBoolean(requireError); + } + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(indices), indicesOptions, requireError); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj.getClass() != getClass()) { + return false; + } + RetryActionRequest other = (RetryActionRequest) obj; + return Objects.deepEquals(indices, other.indices) + && Objects.equals(indicesOptions, other.indicesOptions) + && requireError == other.requireError; + } + +} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java index a34c17cfee42b..244d393858cbd 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/user/InternalUsers.java @@ -30,6 +30,7 @@ import org.elasticsearch.action.search.TransportSearchScrollAction; import org.elasticsearch.index.reindex.ReindexAction; import org.elasticsearch.xpack.core.XPackPlugin; +import org.elasticsearch.xpack.core.ilm.action.ILMActions; import org.elasticsearch.xpack.core.security.authz.RoleDescriptor; import org.elasticsearch.xpack.core.security.support.MetadataUtils; @@ -222,7 +223,8 @@ public class InternalUsers { TransportBulkAction.NAME, TransportIndexAction.NAME, TransportSearchScrollAction.TYPE.name(), - ModifyDataStreamsAction.NAME + ModifyDataStreamsAction.NAME, + ILMActions.RETRY.name() ) .allowRestrictedIndices(false) .build() }, diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java index 1000bd1e68249..6aea4fbf85091 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/RestRetryAction.java @@ -15,6 +15,7 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; import org.elasticsearch.xpack.core.ilm.action.ILMActions; +import org.elasticsearch.xpack.core.ilm.action.RetryActionRequest; import java.util.List; @@ -37,7 +38,7 @@ public String getName() { @Override protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) { final var indices = Strings.splitStringByCommaToArray(restRequest.param("index")); - final var request = new TransportRetryAction.Request(getMasterNodeTimeout(restRequest), getAckTimeout(restRequest), indices); + final var request = new RetryActionRequest(getMasterNodeTimeout(restRequest), getAckTimeout(restRequest), indices); request.indices(indices); request.indicesOptions(IndicesOptions.fromRequest(restRequest, IndicesOptions.strictExpandOpen())); return channel -> client.execute(ILMActions.RETRY, request, new RestToXContentListener<>(channel)); diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java index 13c75dccaa4d3..640e3f69d93f4 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java @@ -10,11 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.AckedClusterStateUpdateTask; @@ -25,24 +21,18 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.core.SuppressForbidden; -import org.elasticsearch.core.TimeValue; import org.elasticsearch.injection.guice.Inject; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ilm.Step.StepKey; import org.elasticsearch.xpack.core.ilm.action.ILMActions; +import org.elasticsearch.xpack.core.ilm.action.RetryActionRequest; import org.elasticsearch.xpack.ilm.IndexLifecycleService; -import java.io.IOException; -import java.util.Arrays; -import java.util.Objects; - -public class TransportRetryAction extends TransportMasterNodeAction { +public class TransportRetryAction extends TransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportRetryAction.class); @@ -62,7 +52,7 @@ public TransportRetryAction( clusterService, threadPool, actionFilters, - Request::new, + RetryActionRequest::new, AcknowledgedResponse::readFrom, EsExecutors.DIRECT_EXECUTOR_SERVICE ); @@ -70,7 +60,12 @@ public TransportRetryAction( } @Override - protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) { + protected void masterOperation(Task task, RetryActionRequest request, ClusterState state, ActionListener listener) { + if (request.requireError() == false) { + maybeRunAsyncAction(state, request.indices()); + listener.onResponse(AcknowledgedResponse.TRUE); + return; + } submitUnbatchedTask("ilm-re-run", new AckedClusterStateUpdateTask(request, listener) { @Override public ClusterState execute(ClusterState currentState) { @@ -79,101 +74,37 @@ public ClusterState execute(ClusterState currentState) { @Override public void clusterStateProcessed(ClusterState oldState, ClusterState newState) { - for (String index : request.indices()) { - IndexMetadata idxMeta = newState.metadata().getProject().index(index); - LifecycleExecutionState lifecycleState = idxMeta.getLifecycleExecutionState(); - StepKey retryStep = new StepKey(lifecycleState.phase(), lifecycleState.action(), lifecycleState.step()); - if (idxMeta == null) { - // The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case. - logger.debug( - "index [" - + index - + "] has been deleted after moving to step [" - + lifecycleState.step() - + "], skipping async action check" - ); - return; - } - indexLifecycleService.maybeRunAsyncAction(newState, idxMeta, retryStep); - } + maybeRunAsyncAction(newState, request.indices()); } }); } + private void maybeRunAsyncAction(ClusterState state, String[] indices) { + for (String index : indices) { + IndexMetadata idxMeta = state.metadata().getProject().index(index); + if (idxMeta == null) { + // The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case. + logger.debug( + "index [" + + index + + "] has been deleted, skipping async action check" + ); + return; + } + LifecycleExecutionState lifecycleState = idxMeta.getLifecycleExecutionState(); + StepKey retryStep = new StepKey(lifecycleState.phase(), lifecycleState.action(), lifecycleState.step()); + indexLifecycleService.maybeRunAsyncAction(state, idxMeta, retryStep); + } + } + @SuppressForbidden(reason = "legacy usage of unbatched task") // TODO add support for batching here private void submitUnbatchedTask(@SuppressWarnings("SameParameterValue") String source, ClusterStateUpdateTask task) { clusterService.submitUnbatchedStateUpdateTask(source, task); } @Override - protected ClusterBlockException checkBlock(Request request, ClusterState state) { + protected ClusterBlockException checkBlock(RetryActionRequest request, ClusterState state) { return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); } - public static class Request extends AcknowledgedRequest implements IndicesRequest.Replaceable { - private String[] indices; - private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); - - public Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, String... indices) { - super(masterNodeTimeout, ackTimeout); - this.indices = indices; - } - - public Request(StreamInput in) throws IOException { - super(in); - this.indices = in.readStringArray(); - this.indicesOptions = IndicesOptions.readIndicesOptions(in); - } - - @Override - public Request indices(String... indices) { - this.indices = indices; - return this; - } - - @Override - public String[] indices() { - return indices; - } - - @Override - public IndicesOptions indicesOptions() { - return indicesOptions; - } - - public Request indicesOptions(IndicesOptions indicesOptions) { - this.indicesOptions = indicesOptions; - return this; - } - - @Override - public ActionRequestValidationException validate() { - return null; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeStringArray(indices); - indicesOptions.writeIndicesOptions(out); - } - - @Override - public int hashCode() { - return Objects.hash(Arrays.hashCode(indices), indicesOptions); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (obj.getClass() != getClass()) { - return false; - } - Request other = (Request) obj; - return Objects.deepEquals(indices, other.indices) && Objects.equals(indicesOptions, other.indicesOptions); - } - - } } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/RetryRequestTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/RetryRequestTests.java index 4f053ddc2caa4..67fcc781f1edd 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/RetryRequestTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/action/RetryRequestTests.java @@ -11,14 +11,15 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.test.AbstractWireSerializingTestCase; +import org.elasticsearch.xpack.core.ilm.action.RetryActionRequest; import java.util.Arrays; -public class RetryRequestTests extends AbstractWireSerializingTestCase { +public class RetryRequestTests extends AbstractWireSerializingTestCase { @Override - protected TransportRetryAction.Request createTestInstance() { - final var request = new TransportRetryAction.Request( + protected RetryActionRequest createTestInstance() { + final var request = new RetryActionRequest( TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT, randomBoolean() ? Strings.EMPTY_ARRAY : generateRandomStringArray(20, 20, false) @@ -36,19 +37,23 @@ protected TransportRetryAction.Request createTestInstance() { ); request.indicesOptions(indicesOptions); } + if (randomBoolean()) { + request.requireError(randomBoolean()); + } return request; } @Override - protected Writeable.Reader instanceReader() { - return TransportRetryAction.Request::new; + protected Writeable.Reader instanceReader() { + return RetryActionRequest::new; } @Override - protected TransportRetryAction.Request mutateInstance(TransportRetryAction.Request instance) { + protected RetryActionRequest mutateInstance(RetryActionRequest instance) { String[] indices = instance.indices(); IndicesOptions indicesOptions = instance.indicesOptions(); - switch (between(0, 1)) { + boolean requireError = instance.requireError(); + switch (between(0, 2)) { case 0 -> indices = randomValueOtherThanMany( i -> Arrays.equals(i, instance.indices()), () -> generateRandomStringArray(20, 10, false, true) @@ -66,10 +71,12 @@ protected TransportRetryAction.Request mutateInstance(TransportRetryAction.Reque randomBoolean() ) ); + case 2 -> requireError = requireError == false; default -> throw new AssertionError("Illegal randomisation branch"); } - final var newRequest = new TransportRetryAction.Request(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT, indices); + final var newRequest = new RetryActionRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT, indices); newRequest.indicesOptions(indicesOptions); + newRequest.requireError(requireError); return newRequest; } } diff --git a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java index 6c69b7d6a19cb..a51ef3400fd6e 100644 --- a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java @@ -40,6 +40,8 @@ import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.core.ilm.action.ILMActions; +import org.elasticsearch.xpack.core.ilm.action.RetryActionRequest; import org.elasticsearch.xpack.migrate.action.ReindexDataStreamIndexAction; import java.util.ArrayList; @@ -265,13 +267,26 @@ private void copySettings(String oldIndex, String newIndex, ActionListener { + maybeRunILMAsyncAction(newIndex, delegate2, parentTaskId); + }) + ); } else { delegate.onResponse(null); } })); } + private void maybeRunILMAsyncAction(String newIndex, ActionListener listener, TaskId parentTaskId) { + var retryActionRequest = new RetryActionRequest(TimeValue.MAX_VALUE, TimeValue.MAX_VALUE, newIndex); + retryActionRequest.setParentTask(parentTaskId); + retryActionRequest.requireError(false); + client.execute(ILMActions.RETRY, retryActionRequest, listener); + } + private void deleteIndex(String indexName, TaskId parentTaskId, ActionListener listener) { DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName); deleteIndexRequest.setParentTask(parentTaskId); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java index 1d320f97a41a2..af62ed8d26c4b 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java @@ -29,6 +29,7 @@ import org.elasticsearch.core.Strings; import org.elasticsearch.xcontent.json.JsonXContent; import org.hamcrest.Matchers; +import org.junit.Before; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -44,6 +45,17 @@ public class DataStreamsUpgradeIT extends AbstractUpgradeTestCase { + @Before + public void setupILMSettings() throws IOException { + Request request = new Request("PUT", "/_cluster/settings"); + request.setJsonEntity( + """ + { "persistent": {"indices.lifecycle.poll_interval": "1s"} } + """ + ); + assertOK(client().performRequest(request)); + } + public void testDataStreams() throws IOException { if (CLUSTER_TYPE == ClusterType.OLD) { String requestBody = """ @@ -193,15 +205,26 @@ public void testUpgradeDataStream() throws Exception { String dataStreamName = "reindex_test_data_stream"; String dataStreamFromNonDataStreamIndices = "index_first_reindex_test_data_stream"; int numRollovers = randomIntBetween(0, 5); + boolean hasILMPolicy = randomBoolean(); + boolean ilmEnabled = hasILMPolicy && randomBoolean(); + if (CLUSTER_TYPE == ClusterType.OLD) { - createAndRolloverDataStream(dataStreamName, numRollovers); + createAndRolloverDataStream(dataStreamName, numRollovers, hasILMPolicy, ilmEnabled); createDataStreamFromNonDataStreamIndices(dataStreamFromNonDataStreamIndices); } else if (CLUSTER_TYPE == ClusterType.UPGRADED) { + if (ilmEnabled) { + enableILM(); + } Map> oldIndicesMetadata = getIndicesMetadata(dataStreamName); upgradeDataStream(dataStreamName, numRollovers, numRollovers + 1, 0); upgradeDataStream(dataStreamFromNonDataStreamIndices, 0, 1, 0); Map> upgradedIndicesMetadata = getIndicesMetadata(dataStreamName); - compareIndexMetadata(oldIndicesMetadata, upgradedIndicesMetadata); + + if (ilmEnabled) { + checkILMPhase(dataStreamName, upgradedIndicesMetadata); + } else { + compareIndexMetadata(oldIndicesMetadata, upgradedIndicesMetadata); + } } } @@ -231,6 +254,24 @@ private void compareIndexMetadata( } } + @SuppressWarnings("unchecked") + private void checkILMPhase(String dataStreamName, Map> upgradedIndicesMetadata) throws Exception { + var writeIndex = getWriteIndexFromDataStreamIndexMetadata(upgradedIndicesMetadata); + assertBusy(() -> { + + Request request = new Request("GET", dataStreamName + "/_ilm/explain"); + Response response = client().performRequest(request); + Map responseMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), false); + Map indices = (Map) responseMap.get("indices"); + for (var index : indices.keySet()) { + if (index.equals(writeIndex) == false) { + Map ilmInfo = (Map) indices.get(index); + assertThat("Index has not moved to cold ILM phase", ilmInfo.get("phase"), equalTo("cold")); + } + } + }); + } + private String getWriteIndexFromDataStreamIndexMetadata(Map> indexMetadataForDataStream) { return indexMetadataForDataStream.entrySet() .stream() @@ -240,6 +281,11 @@ private String getWriteIndexFromDataStreamIndexMetadata(Map indexMetadata) { return Long.parseLong( @@ -273,9 +319,8 @@ private Map getIndexSettingsFromIndexMetadata(Map) ((Map) indexMetadata.get("settings")).get("index"); } - private void createAndRolloverDataStream(String dataStreamName, int numRollovers) throws IOException { - boolean useIlm = randomBoolean(); - if (useIlm) { + private void createAndRolloverDataStream(String dataStreamName, int numRollovers, boolean hasILMPolicy, boolean ilmEnabled) throws IOException { + if (hasILMPolicy) { createIlmPolicy(); } // We want to create a data stream and roll it over several times so that we have several indices to upgrade @@ -333,7 +378,7 @@ private void createAndRolloverDataStream(String dataStreamName, int numRollovers } } """; - if (useIlm) { + if (hasILMPolicy) { template = template.replace("$ILM_SETTING", """ "lifecycle.name": "test-lifecycle-policy", """); @@ -359,7 +404,7 @@ private void createAndRolloverDataStream(String dataStreamName, int numRollovers bulkLoadData(dataStreamName); for (int i = 0; i < numRollovers; i++) { String oldIndexName = rollover(dataStreamName); - if (randomBoolean()) { + if (ilmEnabled ==false && randomBoolean()) { closeIndex(oldIndexName); } bulkLoadData(dataStreamName); @@ -371,21 +416,18 @@ private static void createIlmPolicy() throws IOException { { "policy": { "phases": { - "hot": { + "warm": { + "min_age": "1s", "actions": { - "rollover": { - "max_primary_shard_size": "50kb" + "forcemerge": { + "max_num_segments": 1 } } }, - "warm": { - "min_age": "30d", + "cold": { "actions": { - "shrink": { - "number_of_shards": 1 - }, - "forcemerge": { - "max_num_segments": 1 + "set_priority" : { + "priority": 50 } } } From a85b5596cda9f1325c5479da1fb3e5ac5f40aa0e Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 14:43:45 -0600 Subject: [PATCH 02/13] Do not test closed indices if ILM is enabled --- .../elasticsearch/upgrades/DataStreamsUpgradeIT.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java index af62ed8d26c4b..27190eec58b50 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java @@ -216,8 +216,8 @@ public void testUpgradeDataStream() throws Exception { enableILM(); } Map> oldIndicesMetadata = getIndicesMetadata(dataStreamName); - upgradeDataStream(dataStreamName, numRollovers, numRollovers + 1, 0); - upgradeDataStream(dataStreamFromNonDataStreamIndices, 0, 1, 0); + upgradeDataStream(dataStreamName, numRollovers, numRollovers + 1, 0, ilmEnabled); + upgradeDataStream(dataStreamFromNonDataStreamIndices, 0, 1, 0, ilmEnabled); Map> upgradedIndicesMetadata = getIndicesMetadata(dataStreamName); if (ilmEnabled) { @@ -269,7 +269,7 @@ private void checkILMPhase(String dataStreamName, Map> indexMetadataForDataStream) { @@ -581,13 +581,13 @@ private void createDataStreamFromNonDataStreamIndices(String dataStreamFromNonDa } @SuppressWarnings("unchecked") - private void upgradeDataStream(String dataStreamName, int numRolloversOnOldCluster, int expectedSuccessesCount, int expectedErrorCount) + private void upgradeDataStream(String dataStreamName, int numRolloversOnOldCluster, int expectedSuccessesCount, int expectedErrorCount, boolean ilmEnabled) throws Exception { Set indicesNeedingUpgrade = getDataStreamIndices(dataStreamName); final int explicitRolloverOnNewClusterCount = randomIntBetween(0, 2); for (int i = 0; i < explicitRolloverOnNewClusterCount; i++) { String oldIndexName = rollover(dataStreamName); - if (randomBoolean()) { + if (ilmEnabled == false && randomBoolean()) { closeIndex(oldIndexName); } } From 192d6cd240456204651e156b9461b58212aa7579 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 14:48:54 -0600 Subject: [PATCH 03/13] transport version should use isPatch for previous versions --- .../xpack/core/ilm/action/RetryActionRequest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java index 78eab303667a4..ea74c82872497 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java @@ -35,9 +35,9 @@ public RetryActionRequest(StreamInput in) throws IOException { this.indices = in.readStringArray(); this.indicesOptions = IndicesOptions.readIndicesOptions(in); if (in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR) - || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) - || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) - || in.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { + || in.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) + || in.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) + || in.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { this.requireError = in.readBoolean(); } } @@ -82,9 +82,9 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); if (out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR) - || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) - || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) - || out.getTransportVersion().onOrAfter(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { + || out.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90) + || out.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_19) + || out.getTransportVersion().isPatchFrom(TransportVersions.RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18)) { out.writeBoolean(requireError); } } From 06e4bba1e1bf3d20f08d26dc6759f76b0ff7209b Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Wed, 5 Mar 2025 20:57:45 +0000 Subject: [PATCH 04/13] [CI] Auto commit changes from spotless --- .../ilm/action/TransportRetryAction.java | 13 +++++----- .../upgrades/DataStreamsUpgradeIT.java | 26 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java index 640e3f69d93f4..a00a50f061b42 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRetryAction.java @@ -60,7 +60,12 @@ public TransportRetryAction( } @Override - protected void masterOperation(Task task, RetryActionRequest request, ClusterState state, ActionListener listener) { + protected void masterOperation( + Task task, + RetryActionRequest request, + ClusterState state, + ActionListener listener + ) { if (request.requireError() == false) { maybeRunAsyncAction(state, request.indices()); listener.onResponse(AcknowledgedResponse.TRUE); @@ -84,11 +89,7 @@ private void maybeRunAsyncAction(ClusterState state, String[] indices) { IndexMetadata idxMeta = state.metadata().getProject().index(index); if (idxMeta == null) { // The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case. - logger.debug( - "index [" - + index - + "] has been deleted, skipping async action check" - ); + logger.debug("index [" + index + "] has been deleted, skipping async action check"); return; } LifecycleExecutionState lifecycleState = idxMeta.getLifecycleExecutionState(); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java index 27190eec58b50..5d0c30f5c35ae 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java @@ -48,11 +48,9 @@ public class DataStreamsUpgradeIT extends AbstractUpgradeTestCase { @Before public void setupILMSettings() throws IOException { Request request = new Request("PUT", "/_cluster/settings"); - request.setJsonEntity( - """ + request.setJsonEntity(""" { "persistent": {"indices.lifecycle.poll_interval": "1s"} } - """ - ); + """); assertOK(client().performRequest(request)); } @@ -261,7 +259,11 @@ private void checkILMPhase(String dataStreamName, Map responseMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), false); + Map responseMap = XContentHelper.convertToMap( + JsonXContent.jsonXContent, + response.getEntity().getContent(), + false + ); Map indices = (Map) responseMap.get("indices"); for (var index : indices.keySet()) { if (index.equals(writeIndex) == false) { @@ -319,7 +321,8 @@ private Map getIndexSettingsFromIndexMetadata(Map) ((Map) indexMetadata.get("settings")).get("index"); } - private void createAndRolloverDataStream(String dataStreamName, int numRollovers, boolean hasILMPolicy, boolean ilmEnabled) throws IOException { + private void createAndRolloverDataStream(String dataStreamName, int numRollovers, boolean hasILMPolicy, boolean ilmEnabled) + throws IOException { if (hasILMPolicy) { createIlmPolicy(); } @@ -404,7 +407,7 @@ private void createAndRolloverDataStream(String dataStreamName, int numRollovers bulkLoadData(dataStreamName); for (int i = 0; i < numRollovers; i++) { String oldIndexName = rollover(dataStreamName); - if (ilmEnabled ==false && randomBoolean()) { + if (ilmEnabled == false && randomBoolean()) { closeIndex(oldIndexName); } bulkLoadData(dataStreamName); @@ -581,8 +584,13 @@ private void createDataStreamFromNonDataStreamIndices(String dataStreamFromNonDa } @SuppressWarnings("unchecked") - private void upgradeDataStream(String dataStreamName, int numRolloversOnOldCluster, int expectedSuccessesCount, int expectedErrorCount, boolean ilmEnabled) - throws Exception { + private void upgradeDataStream( + String dataStreamName, + int numRolloversOnOldCluster, + int expectedSuccessesCount, + int expectedErrorCount, + boolean ilmEnabled + ) throws Exception { Set indicesNeedingUpgrade = getDataStreamIndices(dataStreamName); final int explicitRolloverOnNewClusterCount = randomIntBetween(0, 2); for (int i = 0; i < explicitRolloverOnNewClusterCount; i++) { From 3fba6435d90ce7ff7ab10acaf3e30fce424d4a94 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 15:25:40 -0600 Subject: [PATCH 05/13] by default retry should require ilm error --- .../elasticsearch/xpack/core/ilm/action/RetryActionRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java index ea74c82872497..c2c9d5d840596 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/action/RetryActionRequest.java @@ -23,7 +23,7 @@ public class RetryActionRequest extends AcknowledgedRequest implements IndicesRequest.Replaceable { private String[] indices; private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); - private boolean requireError = false; + private boolean requireError = true; public RetryActionRequest(TimeValue masterNodeTimeout, TimeValue ackTimeout, String... indices) { super(masterNodeTimeout, ackTimeout); From 371ebb1b74eec730e7dd477d81a0953cc71a02f3 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 15:45:35 -0600 Subject: [PATCH 06/13] add comment --- .../task/ReindexDataStreamPersistentTaskExecutor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java index a51ef3400fd6e..a817a61617d36 100644 --- a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java @@ -280,6 +280,14 @@ private void copySettings(String oldIndex, String newIndex, ActionListener listener, TaskId parentTaskId) { var retryActionRequest = new RetryActionRequest(TimeValue.MAX_VALUE, TimeValue.MAX_VALUE, newIndex); retryActionRequest.setParentTask(parentTaskId); From 9ce5e226d6491a03b3f267b2d00c059e82a5fff2 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 20:40:25 -0600 Subject: [PATCH 07/13] Skip async action if next step is empty --- .../xpack/ilm/IndexLifecycleRunner.java | 7 +++- .../upgrades/DataStreamsUpgradeIT.java | 35 +++++++++++-------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java index c8cd76c1fe26f..a9a24cca54894 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java @@ -322,7 +322,12 @@ void maybeRunAsyncAction(ClusterState currentState, IndexMetadata indexMetadata, logger.warn("current step [{}] for index [{}] with policy [{}] is not recognized", currentStepKey, index, policy); return; } - + if (expectedStepKey.phase() == null && expectedStepKey.name() == null && expectedStepKey.action() == null) { + // ILM is stopped, so do not try to run async action + logger.debug("expected step for index [{}] with policy [{}] is [{}], not running async action", + currentStep.getKey(), index, policy); + return; + } logger.trace( "[{}] maybe running async action step ({}) with current step {}", index, diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java index 5d0c30f5c35ae..0f3040d33ead6 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java @@ -29,7 +29,6 @@ import org.elasticsearch.core.Strings; import org.elasticsearch.xcontent.json.JsonXContent; import org.hamcrest.Matchers; -import org.junit.Before; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -45,15 +44,6 @@ public class DataStreamsUpgradeIT extends AbstractUpgradeTestCase { - @Before - public void setupILMSettings() throws IOException { - Request request = new Request("PUT", "/_cluster/settings"); - request.setJsonEntity(""" - { "persistent": {"indices.lifecycle.poll_interval": "1s"} } - """); - assertOK(client().performRequest(request)); - } - public void testDataStreams() throws IOException { if (CLUSTER_TYPE == ClusterType.OLD) { String requestBody = """ @@ -206,13 +196,16 @@ public void testUpgradeDataStream() throws Exception { boolean hasILMPolicy = randomBoolean(); boolean ilmEnabled = hasILMPolicy && randomBoolean(); + if (ilmEnabled) { + startILM(); + } else { + stopILM(); + } + if (CLUSTER_TYPE == ClusterType.OLD) { createAndRolloverDataStream(dataStreamName, numRollovers, hasILMPolicy, ilmEnabled); createDataStreamFromNonDataStreamIndices(dataStreamFromNonDataStreamIndices); } else if (CLUSTER_TYPE == ClusterType.UPGRADED) { - if (ilmEnabled) { - enableILM(); - } Map> oldIndicesMetadata = getIndicesMetadata(dataStreamName); upgradeDataStream(dataStreamName, numRollovers, numRollovers + 1, 0, ilmEnabled); upgradeDataStream(dataStreamFromNonDataStreamIndices, 0, 1, 0, ilmEnabled); @@ -283,11 +276,25 @@ private String getWriteIndexFromDataStreamIndexMetadata(Map indexMetadata) { return Long.parseLong( From bcfe0753d4cc617c091f898553e507b4d07e4f4a Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Thu, 6 Mar 2025 02:46:10 +0000 Subject: [PATCH 08/13] [CI] Auto commit changes from spotless --- .../org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java index a9a24cca54894..48774a8a68abb 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java @@ -324,8 +324,12 @@ void maybeRunAsyncAction(ClusterState currentState, IndexMetadata indexMetadata, } if (expectedStepKey.phase() == null && expectedStepKey.name() == null && expectedStepKey.action() == null) { // ILM is stopped, so do not try to run async action - logger.debug("expected step for index [{}] with policy [{}] is [{}], not running async action", - currentStep.getKey(), index, policy); + logger.debug( + "expected step for index [{}] with policy [{}] is [{}], not running async action", + currentStep.getKey(), + index, + policy + ); return; } logger.trace( From 0d3dedf460fb349dbadf935075bb4dd1976b305a Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Wed, 5 Mar 2025 21:29:46 -0600 Subject: [PATCH 09/13] variables in log in wrong order --- .../org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java index 48774a8a68abb..052b8f4e52027 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java @@ -326,9 +326,9 @@ void maybeRunAsyncAction(ClusterState currentState, IndexMetadata indexMetadata, // ILM is stopped, so do not try to run async action logger.debug( "expected step for index [{}] with policy [{}] is [{}], not running async action", - currentStep.getKey(), index, - policy + policy, + expectedStepKey ); return; } From 38b057039c29aec1350890204c0c4b61b3b0b277 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Thu, 6 Mar 2025 03:35:50 +0000 Subject: [PATCH 10/13] [CI] Auto commit changes from spotless --- .../org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java index 052b8f4e52027..21a2af2b97168 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunner.java @@ -324,12 +324,7 @@ void maybeRunAsyncAction(ClusterState currentState, IndexMetadata indexMetadata, } if (expectedStepKey.phase() == null && expectedStepKey.name() == null && expectedStepKey.action() == null) { // ILM is stopped, so do not try to run async action - logger.debug( - "expected step for index [{}] with policy [{}] is [{}], not running async action", - index, - policy, - expectedStepKey - ); + logger.debug("expected step for index [{}] with policy [{}] is [{}], not running async action", index, policy, expectedStepKey); return; } logger.trace( From d3e680f4c2736b484d001f5054b99606116c63de Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Thu, 6 Mar 2025 09:13:50 -0600 Subject: [PATCH 11/13] Don't use time series index as complicates ILM tests --- .../org/elasticsearch/upgrades/DataStreamsUpgradeIT.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java index 0f3040d33ead6..e6332417cd70f 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java @@ -339,7 +339,7 @@ private void createAndRolloverDataStream(String dataStreamName, int numRollovers "settings":{ "index": { $ILM_SETTING - "mode": "time_series" + "mode": "standard" } }, $DSL_TEMPLATE @@ -360,8 +360,7 @@ private void createAndRolloverDataStream(String dataStreamName, int numRollovers "type": "date" }, "metricset": { - "type": "keyword", - "time_series_dimension": true + "type": "keyword" }, "k8s": { "properties": { From db24d5516c8c5711ec167d182e2a7a78b4224cd9 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Thu, 6 Mar 2025 11:21:21 -0600 Subject: [PATCH 12/13] Update docs/changelog/124149.yaml --- docs/changelog/124149.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/124149.yaml diff --git a/docs/changelog/124149.yaml b/docs/changelog/124149.yaml new file mode 100644 index 0000000000000..07c2f396efda3 --- /dev/null +++ b/docs/changelog/124149.yaml @@ -0,0 +1,5 @@ +pr: 124149 +summary: Retry ILM async action after reindexing data stream +area: Data streams +type: enhancement +issues: [] From 7ad2d49ef836cd7818103958f079d84c9742b418 Mon Sep 17 00:00:00 2001 From: Parker Timmins Date: Thu, 6 Mar 2025 11:28:47 -0600 Subject: [PATCH 13/13] Missing semicolon! --- server/src/main/java/org/elasticsearch/TransportVersions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index be791231c0e8e..9d2744f865b09 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -186,7 +186,7 @@ static TransportVersion def(int id) { public static final TransportVersion UNASSIGENEDINFO_RESHARD_ADDED = def(9_022_0_00); public static final TransportVersion INCLUDE_INDEX_MODE_IN_GET_DATA_STREAM = def(9_023_0_00); public static final TransportVersion MAX_OPERATION_SIZE_REJECTIONS_ADDED = def(9_024_0_00); - public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR = def(9_025_0_00) + public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR = def(9_025_0_00); /* * STOP! READ THIS FIRST! No, really,