77package org .elasticsearch .xpack .deprecation ;
88
99import org .elasticsearch .Version ;
10- import org .elasticsearch .cluster .ClusterState ;
1110import org .elasticsearch .cluster .metadata .IndexMetadata ;
1211import org .elasticsearch .cluster .metadata .IndexNameExpressionResolver ;
1312import org .elasticsearch .cluster .metadata .MappingMetadata ;
13+ import org .elasticsearch .cluster .metadata .ProjectMetadata ;
1414import org .elasticsearch .common .TriFunction ;
1515import org .elasticsearch .common .time .DateFormatter ;
1616import org .elasticsearch .common .time .LegacyFormatNames ;
@@ -44,7 +44,7 @@ public class IndexDeprecationChecker implements ResourceDeprecationChecker {
4444 public static final String NAME = "index_settings" ;
4545
4646 private final IndexNameExpressionResolver indexNameExpressionResolver ;
47- private final List <TriFunction <IndexMetadata , ClusterState , Map <String , List <String >>, DeprecationIssue >> checks = List .of (
47+ private final List <TriFunction <IndexMetadata , ProjectMetadata , Map <String , List <String >>, DeprecationIssue >> checks = List .of (
4848 this ::oldIndicesCheck ,
4949 this ::ignoredOldIndicesCheck ,
5050 this ::translogRetentionSettingCheck ,
@@ -60,17 +60,17 @@ public IndexDeprecationChecker(IndexNameExpressionResolver indexNameExpressionRe
6060
6161 @ Override
6262 public Map <String , List <DeprecationIssue >> check (
63- ClusterState clusterState ,
63+ ProjectMetadata project ,
6464 DeprecationInfoAction .Request request ,
6565 TransportDeprecationInfoAction .PrecomputedData precomputedData
6666 ) {
6767 Map <String , List <DeprecationIssue >> indexSettingsIssues = new HashMap <>();
68- String [] concreteIndexNames = indexNameExpressionResolver .concreteIndexNames (clusterState , request );
68+ String [] concreteIndexNames = indexNameExpressionResolver .concreteIndexNames (project , request );
6969 Map <String , List <String >> indexToTransformIds = indexToTransformIds (precomputedData .transformConfigs ());
7070 for (String concreteIndex : concreteIndexNames ) {
71- IndexMetadata indexMetadata = clusterState . getMetadata (). getProject () .index (concreteIndex );
71+ IndexMetadata indexMetadata = project .index (concreteIndex );
7272 List <DeprecationIssue > singleIndexIssues = checks .stream ()
73- .map (c -> c .apply (indexMetadata , clusterState , indexToTransformIds ))
73+ .map (c -> c .apply (indexMetadata , project , indexToTransformIds ))
7474 .filter (Objects ::nonNull )
7575 .toList ();
7676 if (singleIndexIssues .isEmpty () == false ) {
@@ -90,13 +90,13 @@ public String getName() {
9090
9191 private DeprecationIssue oldIndicesCheck (
9292 IndexMetadata indexMetadata ,
93- ClusterState clusterState ,
93+ ProjectMetadata project ,
9494 Map <String , List <String >> indexToTransformIds
9595 ) {
9696 // TODO: this check needs to be revised. It's trivially true right now.
9797 IndexVersion currentCompatibilityVersion = indexMetadata .getCompatibilityVersion ();
9898 // We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
99- if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , false , false ) && isNotDataStreamIndex (indexMetadata , clusterState )) {
99+ if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , false , false ) && isNotDataStreamIndex (indexMetadata , project )) {
100100 var transforms = transformIdsForIndex (indexMetadata , indexToTransformIds );
101101 if (transforms .isEmpty () == false ) {
102102 return new DeprecationIssue (
@@ -134,12 +134,12 @@ private List<String> transformIdsForIndex(IndexMetadata indexMetadata, Map<Strin
134134
135135 private DeprecationIssue ignoredOldIndicesCheck (
136136 IndexMetadata indexMetadata ,
137- ClusterState clusterState ,
137+ ProjectMetadata project ,
138138 Map <String , List <String >> indexToTransformIds
139139 ) {
140140 IndexVersion currentCompatibilityVersion = indexMetadata .getCompatibilityVersion ();
141141 // We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
142- if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , true , false ) && isNotDataStreamIndex (indexMetadata , clusterState )) {
142+ if (DeprecatedIndexPredicate .reindexRequired (indexMetadata , true , false ) && isNotDataStreamIndex (indexMetadata , project )) {
143143 var transforms = transformIdsForIndex (indexMetadata , indexToTransformIds );
144144 if (transforms .isEmpty () == false ) {
145145 return new DeprecationIssue (
@@ -175,13 +175,13 @@ private DeprecationIssue ignoredOldIndicesCheck(
175175 return null ;
176176 }
177177
178- private boolean isNotDataStreamIndex (IndexMetadata indexMetadata , ClusterState clusterState ) {
179- return clusterState . metadata (). getProject () .findDataStreams (indexMetadata .getIndex ().getName ()).isEmpty ();
178+ private boolean isNotDataStreamIndex (IndexMetadata indexMetadata , ProjectMetadata project ) {
179+ return project .findDataStreams (indexMetadata .getIndex ().getName ()).isEmpty ();
180180 }
181181
182182 private DeprecationIssue translogRetentionSettingCheck (
183183 IndexMetadata indexMetadata ,
184- ClusterState clusterState ,
184+ ProjectMetadata project ,
185185 Map <String , List <String >> ignored
186186 ) {
187187 final boolean softDeletesEnabled = IndexSettings .INDEX_SOFT_DELETES_SETTING .get (indexMetadata .getSettings ());
@@ -210,7 +210,7 @@ private DeprecationIssue translogRetentionSettingCheck(
210210 return null ;
211211 }
212212
213- private DeprecationIssue checkIndexDataPath (IndexMetadata indexMetadata , ClusterState clusterState , Map <String , List <String >> ignored ) {
213+ private DeprecationIssue checkIndexDataPath (IndexMetadata indexMetadata , ProjectMetadata project , Map <String , List <String >> ignored ) {
214214 if (IndexMetadata .INDEX_DATA_PATH_SETTING .exists (indexMetadata .getSettings ())) {
215215 final String message = String .format (
216216 Locale .ROOT ,
@@ -226,7 +226,7 @@ private DeprecationIssue checkIndexDataPath(IndexMetadata indexMetadata, Cluster
226226
227227 private DeprecationIssue storeTypeSettingCheck (
228228 IndexMetadata indexMetadata ,
229- ClusterState clusterState ,
229+ ProjectMetadata project ,
230230 Map <String , List <String >> ignored
231231 ) {
232232 final String storeType = IndexModule .INDEX_STORE_TYPE_SETTING .get (indexMetadata .getSettings ());
@@ -247,7 +247,7 @@ private DeprecationIssue storeTypeSettingCheck(
247247
248248 private DeprecationIssue legacyRoutingSettingCheck (
249249 IndexMetadata indexMetadata ,
250- ClusterState clusterState ,
250+ ProjectMetadata project ,
251251 Map <String , List <String >> ignored
252252 ) {
253253 List <String > deprecatedSettings = LegacyTiersDetection .getDeprecatedFilteredAllocationSettings (indexMetadata .getSettings ());
@@ -339,7 +339,7 @@ private List<String> findInPropertiesRecursively(
339339
340340 private DeprecationIssue deprecatedCamelCasePattern (
341341 IndexMetadata indexMetadata ,
342- ClusterState clusterState ,
342+ ProjectMetadata project ,
343343 Map <String , List <String >> ignored
344344 ) {
345345 List <String > fields = new ArrayList <>();
0 commit comments