2222import org .elasticsearch .cluster .block .ClusterBlockException ;
2323import org .elasticsearch .cluster .block .ClusterBlockLevel ;
2424import org .elasticsearch .cluster .metadata .IndexMetadata ;
25+ import org .elasticsearch .cluster .project .ProjectResolver ;
2526import org .elasticsearch .cluster .service .ClusterService ;
2627import org .elasticsearch .common .Strings ;
2728import org .elasticsearch .common .io .stream .StreamInput ;
5051public class TransportMoveToStepAction extends TransportMasterNodeAction <TransportMoveToStepAction .Request , AcknowledgedResponse > {
5152 private static final Logger logger = LogManager .getLogger (TransportMoveToStepAction .class );
5253
53- IndexLifecycleService indexLifecycleService ;
54+ private final IndexLifecycleService indexLifecycleService ;
55+ private final ProjectResolver projectResolver ;
5456
5557 @ Inject
5658 public TransportMoveToStepAction (
5759 TransportService transportService ,
5860 ClusterService clusterService ,
5961 ThreadPool threadPool ,
6062 ActionFilters actionFilters ,
61- IndexLifecycleService indexLifecycleService
63+ IndexLifecycleService indexLifecycleService ,
64+ ProjectResolver projectResolver
6265 ) {
6366 super (
6467 ILMActions .MOVE_TO_STEP .name (),
@@ -71,11 +74,13 @@ public TransportMoveToStepAction(
7174 EsExecutors .DIRECT_EXECUTOR_SERVICE
7275 );
7376 this .indexLifecycleService = indexLifecycleService ;
77+ this .projectResolver = projectResolver ;
7478 }
7579
7680 @ Override
7781 protected void masterOperation (Task task , Request request , ClusterState state , ActionListener <AcknowledgedResponse > listener ) {
78- IndexMetadata indexMetadata = state .metadata ().getProject ().index (request .getIndex ());
82+ final var project = projectResolver .getProjectMetadata (state );
83+ IndexMetadata indexMetadata = project .index (request .getIndex ());
7984 if (indexMetadata == null ) {
8085 listener .onFailure (new IllegalArgumentException ("index [" + request .getIndex () + "] does not exist" ));
8186 return ;
@@ -95,7 +100,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
95100 // Resolve the key that could have optional parts into one
96101 // that is totally concrete given the existing policy and index
97102 Step .StepKey concreteTargetStepKey = indexLifecycleService .resolveStepKey (
98- state ,
103+ project ,
99104 indexMetadata .getIndex (),
100105 abstractTargetKey .getPhase (),
101106 abstractTargetKey .getAction (),
@@ -125,8 +130,9 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
125130 public ClusterState execute (ClusterState currentState ) {
126131 // Resolve the key that could have optional parts into one
127132 // that is totally concrete given the existing policy and index
133+ final var currentProject = currentState .metadata ().getProject (project .id ());
128134 Step .StepKey concreteTargetStepKey = indexLifecycleService .resolveStepKey (
129- state ,
135+ currentProject ,
130136 indexMetadata .getIndex (),
131137 abstractTargetKey .getPhase (),
132138 abstractTargetKey .getAction (),
@@ -148,7 +154,7 @@ public ClusterState execute(ClusterState currentState) {
148154
149155 concreteTargetKey .set (concreteTargetStepKey );
150156 final var updatedProject = indexLifecycleService .moveIndexToStep (
151- currentState . metadata (). getProject () ,
157+ currentProject ,
152158 indexMetadata .getIndex (),
153159 request .getCurrentStepKey (),
154160 concreteTargetKey .get ()
@@ -158,7 +164,8 @@ public ClusterState execute(ClusterState currentState) {
158164
159165 @ Override
160166 public void clusterStateProcessed (ClusterState oldState , ClusterState newState ) {
161- IndexMetadata newIndexMetadata = newState .metadata ().getProject ().index (indexMetadata .getIndex ());
167+ final var newProjectState = newState .projectState (project .id ());
168+ IndexMetadata newIndexMetadata = newProjectState .metadata ().index (indexMetadata .getIndex ());
162169 if (newIndexMetadata == null ) {
163170 // The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case.
164171 logger .debug (
0 commit comments