1616import org .elasticsearch .cluster .AckedClusterStateUpdateTask ;
1717import org .elasticsearch .cluster .ClusterState ;
1818import org .elasticsearch .cluster .ClusterStateUpdateTask ;
19+ import org .elasticsearch .cluster .ProjectState ;
1920import org .elasticsearch .cluster .block .ClusterBlockException ;
2021import org .elasticsearch .cluster .block .ClusterBlockLevel ;
2122import org .elasticsearch .cluster .metadata .IndexMetadata ;
2223import org .elasticsearch .cluster .metadata .LifecycleExecutionState ;
24+ import org .elasticsearch .cluster .project .ProjectResolver ;
2325import org .elasticsearch .cluster .service .ClusterService ;
2426import org .elasticsearch .common .util .concurrent .EsExecutors ;
2527import org .elasticsearch .core .SuppressForbidden ;
@@ -36,15 +38,17 @@ public class TransportRetryAction extends TransportMasterNodeAction<RetryActionR
3638
3739 private static final Logger logger = LogManager .getLogger (TransportRetryAction .class );
3840
39- IndexLifecycleService indexLifecycleService ;
41+ private final IndexLifecycleService indexLifecycleService ;
42+ private final ProjectResolver projectResolver ;
4043
4144 @ Inject
4245 public TransportRetryAction (
4346 TransportService transportService ,
4447 ClusterService clusterService ,
4548 ThreadPool threadPool ,
4649 ActionFilters actionFilters ,
47- IndexLifecycleService indexLifecycleService
50+ IndexLifecycleService indexLifecycleService ,
51+ ProjectResolver projectResolver
4852 ) {
4953 super (
5054 ILMActions .RETRY .name (),
@@ -57,6 +61,7 @@ public TransportRetryAction(
5761 EsExecutors .DIRECT_EXECUTOR_SERVICE
5862 );
5963 this .indexLifecycleService = indexLifecycleService ;
64+ this .projectResolver = projectResolver ;
6065 }
6166
6267 @ Override
@@ -66,29 +71,30 @@ protected void masterOperation(
6671 ClusterState state ,
6772 ActionListener <AcknowledgedResponse > listener
6873 ) {
74+ final var projectState = projectResolver .getProjectState (state );
6975 if (request .requireError () == false ) {
70- maybeRunAsyncAction (state , request .indices ());
76+ maybeRunAsyncAction (projectState , request .indices ());
7177 listener .onResponse (AcknowledgedResponse .TRUE );
7278 return ;
7379 }
7480 submitUnbatchedTask ("ilm-re-run" , new AckedClusterStateUpdateTask (request , listener ) {
7581 @ Override
7682 public ClusterState execute (ClusterState currentState ) {
77- final var project = state .metadata ().getProject ();
83+ final var project = state .metadata ().getProject (projectState . projectId () );
7884 final var updatedProject = indexLifecycleService .moveIndicesToPreviouslyFailedStep (project , request .indices ());
7985 return ClusterState .builder (currentState ).putProjectMetadata (updatedProject ).build ();
8086 }
8187
8288 @ Override
8389 public void clusterStateProcessed (ClusterState oldState , ClusterState newState ) {
84- maybeRunAsyncAction (newState , request .indices ());
90+ maybeRunAsyncAction (newState . projectState ( projectState . projectId ()) , request .indices ());
8591 }
8692 });
8793 }
8894
89- private void maybeRunAsyncAction (ClusterState state , String [] indices ) {
95+ private void maybeRunAsyncAction (ProjectState state , String [] indices ) {
9096 for (String index : indices ) {
91- IndexMetadata idxMeta = state .metadata ().getProject (). index (index );
97+ IndexMetadata idxMeta = state .metadata ().index (index );
9298 if (idxMeta == null ) {
9399 // The index has somehow been deleted - there shouldn't be any opportunity for this to happen, but just in case.
94100 logger .debug ("index [" + index + "] has been deleted, skipping async action check" );
0 commit comments