Skip to content

Commit b3817cb

Browse files
authored
Make TransportRemoveIndexLifecyclePolicyAction project-aware (#129364)
Updates the action to resolve the correct project.
1 parent 6998c96 commit b3817cb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/action/TransportRemoveIndexLifecyclePolicyAction.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.cluster.block.ClusterBlockException;
1616
import org.elasticsearch.cluster.block.ClusterBlockLevel;
1717
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
18+
import org.elasticsearch.cluster.project.ProjectResolver;
1819
import org.elasticsearch.cluster.service.ClusterService;
1920
import org.elasticsearch.common.util.concurrent.EsExecutors;
2021
import org.elasticsearch.core.SuppressForbidden;
@@ -33,6 +34,7 @@
3334

3435
public class TransportRemoveIndexLifecyclePolicyAction extends TransportMasterNodeAction<Request, Response> {
3536

37+
private final ProjectResolver projectResolver;
3638
private final IndexNameExpressionResolver indexNameExpressionResolver;
3739

3840
@Inject
@@ -41,6 +43,7 @@ public TransportRemoveIndexLifecyclePolicyAction(
4143
ClusterService clusterService,
4244
ThreadPool threadPool,
4345
ActionFilters actionFilters,
46+
ProjectResolver projectResolver,
4447
IndexNameExpressionResolver indexNameExpressionResolver
4548
) {
4649
super(
@@ -54,6 +57,7 @@ public TransportRemoveIndexLifecyclePolicyAction(
5457
EsExecutors.DIRECT_EXECUTOR_SERVICE
5558
);
5659
this.indexNameExpressionResolver = indexNameExpressionResolver;
60+
this.projectResolver = projectResolver;
5761
}
5862

5963
@Override
@@ -63,15 +67,16 @@ protected ClusterBlockException checkBlock(Request request, ClusterState state)
6367

6468
@Override
6569
protected void masterOperation(Task task, Request request, ClusterState state, ActionListener<Response> listener) throws Exception {
66-
final Index[] indices = indexNameExpressionResolver.concreteIndices(state, request.indicesOptions(), true, request.indices());
70+
final var project = projectResolver.getProjectMetadata(state);
71+
final Index[] indices = indexNameExpressionResolver.concreteIndices(project, request.indicesOptions(), true, request.indices());
6772
submitUnbatchedTask("remove-lifecycle-for-index", new ClusterStateUpdateTask(request.masterNodeTimeout()) {
6873

6974
private final List<String> failedIndexes = new ArrayList<>();
7075

7176
@Override
7277
public ClusterState execute(ClusterState currentState) throws Exception {
73-
final var project = currentState.metadata().getProject();
74-
final var updatedProject = IndexLifecycleTransition.removePolicyForIndexes(indices, project, failedIndexes);
78+
final var currentProjet = currentState.metadata().getProject(project.id());
79+
final var updatedProject = IndexLifecycleTransition.removePolicyForIndexes(indices, currentProjet, failedIndexes);
7580
return ClusterState.builder(currentState).putProjectMetadata(updatedProject).build();
7681
}
7782

0 commit comments

Comments
 (0)