|
7 | 7 |
|
8 | 8 | package org.elasticsearch.xpack.ilm;
|
9 | 9 |
|
| 10 | +import org.elasticsearch.cluster.ClusterState; |
10 | 11 | import org.elasticsearch.cluster.metadata.IndexMetadata;
|
| 12 | +import org.elasticsearch.cluster.metadata.ProjectId; |
| 13 | +import org.elasticsearch.cluster.metadata.ProjectMetadata; |
11 | 14 | import org.elasticsearch.cluster.service.ClusterService;
|
12 | 15 | import org.elasticsearch.common.settings.Setting;
|
13 | 16 | import org.elasticsearch.common.settings.Settings;
|
| 17 | +import org.elasticsearch.core.NotMultiProjectCapable; |
14 | 18 | import org.elasticsearch.core.TimeValue;
|
15 | 19 | import org.elasticsearch.health.Diagnosis;
|
16 | 20 | import org.elasticsearch.health.HealthIndicatorDetails;
|
@@ -210,7 +214,7 @@ public String name() {
|
210 | 214 |
|
211 | 215 | @Override
|
212 | 216 | public HealthIndicatorResult calculate(boolean verbose, int maxAffectedResourcesCount, HealthInfo healthInfo) {
|
213 |
| - final var projectMetadata = clusterService.state().metadata().getProject(); |
| 217 | + final var projectMetadata = getDefaultILMProject(clusterService.state()); |
214 | 218 | var ilmMetadata = projectMetadata.custom(IndexLifecycleMetadata.TYPE, IndexLifecycleMetadata.EMPTY);
|
215 | 219 | final var currentMode = currentILMMode(projectMetadata);
|
216 | 220 | if (ilmMetadata.getPolicyMetadatas().isEmpty()) {
|
@@ -341,14 +345,13 @@ static class StagnatingIndicesFinder {
|
341 | 345 | * @return A list containing the ILM managed indices that are stagnated in any ILM action/step.
|
342 | 346 | */
|
343 | 347 | public List<IndexMetadata> find() {
|
344 |
| - var metadata = clusterService.state().metadata(); |
| 348 | + final var project = getDefaultILMProject(clusterService.state()); |
345 | 349 | var now = nowSupplier.getAsLong();
|
346 | 350 |
|
347 |
| - return metadata.getProject() |
348 |
| - .indices() |
| 351 | + return project.indices() |
349 | 352 | .values()
|
350 | 353 | .stream()
|
351 |
| - .filter(metadata.getProject()::isIndexManagedByILM) |
| 354 | + .filter(project::isIndexManagedByILM) |
352 | 355 | .filter(md -> isStagnated(rules, now, md))
|
353 | 356 | .toList();
|
354 | 357 | }
|
@@ -496,4 +499,13 @@ public boolean test(Long now, IndexMetadata indexMetadata) {
|
496 | 499 | || (maxRetries != null && failedStepRetryCount != null && failedStepRetryCount > maxRetries));
|
497 | 500 | }
|
498 | 501 | }
|
| 502 | + |
| 503 | + /** |
| 504 | + * This method solely exists because we are not making ILM properly project-aware and it's not worth the investment of altering this |
| 505 | + * health indicator to be project-aware. |
| 506 | + */ |
| 507 | + @NotMultiProjectCapable |
| 508 | + private static ProjectMetadata getDefaultILMProject(ClusterState state) { |
| 509 | + return state.metadata().getProject(ProjectId.DEFAULT); |
| 510 | + } |
499 | 511 | }
|
0 commit comments