diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleService.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleService.java index e023a58034ecf..389bac89aaedb 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleService.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleService.java @@ -131,8 +131,7 @@ public IndexLifecycleService( .addSettingsUpdateConsumer(LifecycleSettings.LIFECYCLE_POLL_INTERVAL_SETTING, this::updatePollInterval); } - public void maybeRunAsyncAction(ClusterState clusterState, IndexMetadata indexMetadata, StepKey nextStepKey) { - final var state = clusterState.projectState(); + public void maybeRunAsyncAction(ProjectState state, IndexMetadata indexMetadata, StepKey nextStepKey) { lifecycleRunner.maybeRunAsyncAction(state, indexMetadata, indexMetadata.getLifecyclePolicyName(), nextStepKey); } diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportMoveToStepAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportMoveToStepAction.java index de0dcbd143263..d9b6344c2ceef 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportMoveToStepAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportMoveToStepAction.java @@ -177,7 +177,7 @@ public void clusterStateProcessed(ClusterState oldState, ClusterState newState) ); return; } - indexLifecycleService.maybeRunAsyncAction(newState, newIndexMetadata, concreteTargetKey.get()); + indexLifecycleService.maybeRunAsyncAction(newProjectState, newIndexMetadata, concreteTargetKey.get()); } } ); 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 c70aa94af8684..5c3200c873877 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 @@ -16,10 +16,12 @@ import org.elasticsearch.cluster.AckedClusterStateUpdateTask; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; +import org.elasticsearch.cluster.ProjectState; import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.LifecycleExecutionState; +import org.elasticsearch.cluster.project.ProjectResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.core.SuppressForbidden; @@ -36,7 +38,8 @@ public class TransportRetryAction extends TransportMasterNodeAction listener ) { + final var projectState = projectResolver.getProjectState(state); if (request.requireError() == false) { - maybeRunAsyncAction(state, request.indices()); + maybeRunAsyncAction(projectState, request.indices()); listener.onResponse(AcknowledgedResponse.TRUE); return; } submitUnbatchedTask("ilm-re-run", new AckedClusterStateUpdateTask(request, listener) { @Override public ClusterState execute(ClusterState currentState) { - final var project = state.metadata().getProject(); + final var project = state.metadata().getProject(projectState.projectId()); final var updatedProject = indexLifecycleService.moveIndicesToPreviouslyFailedStep(project, request.indices()); return ClusterState.builder(currentState).putProjectMetadata(updatedProject).build(); } @Override public void clusterStateProcessed(ClusterState oldState, ClusterState newState) { - maybeRunAsyncAction(newState, request.indices()); + maybeRunAsyncAction(newState.projectState(projectState.projectId()), request.indices()); } }); } - private void maybeRunAsyncAction(ClusterState state, String[] indices) { + private void maybeRunAsyncAction(ProjectState state, String[] indices) { for (String index : indices) { - IndexMetadata idxMeta = state.metadata().getProject().index(index); + IndexMetadata idxMeta = state.metadata().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");