@@ -154,12 +154,28 @@ protected ClusterBlockException checkBlock(RolloverRequest request, ClusterState
154154 .build (),
155155 IndicesOptions .GatekeeperOptions .DEFAULT
156156 );
157-
158- return state .blocks ()
159- .indicesBlockedException (
160- ClusterBlockLevel .METADATA_WRITE ,
161- indexNameExpressionResolver .concreteIndexNames (state , indicesOptions , request )
162- );
157+ ResolvedExpression resolvedRolloverTarget = SelectorResolver .parseExpression (request .getRolloverTarget (), request .indicesOptions ());
158+ final IndexAbstraction indexAbstraction = state .metadata ().getIndicesLookup ().get (resolvedRolloverTarget .resource ());
159+ if (indexAbstraction .getType ().equals (IndexAbstraction .Type .DATA_STREAM )) {
160+ DataStream dataStream = (DataStream ) indexAbstraction ;
161+ boolean targetData = resolvedRolloverTarget .selector () != null && resolvedRolloverTarget .selector ().shouldIncludeData ();
162+ boolean targetFailureStore = resolvedRolloverTarget .selector () != null
163+ && resolvedRolloverTarget .selector ().shouldIncludeFailures ();
164+ List <String > indicesToCheck = new ArrayList <>();
165+ if (targetData ) {
166+ indicesToCheck .add (dataStream .getWriteIndex ().getName ());
167+ }
168+ if (targetFailureStore ) {
169+ indicesToCheck .add (dataStream .getWriteFailureIndex ().getName ());
170+ }
171+ return state .blocks ().indicesBlockedException (ClusterBlockLevel .METADATA_WRITE , indicesToCheck .toArray (new String [0 ]));
172+ } else {
173+ return state .blocks ()
174+ .indicesBlockedException (
175+ ClusterBlockLevel .METADATA_WRITE ,
176+ indexNameExpressionResolver .concreteIndexNames (state , indicesOptions , request )
177+ );
178+ }
163179 }
164180
165181 @ Override
0 commit comments