Skip to content

Commit 3fa519a

Browse files
authored
[ML] Add .ml indices to the DoPrefixValidator exceptions (#135171)
1 parent 8003e0b commit 3fa519a

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,14 @@ public abstract class DotPrefixValidator<RequestType> implements MappedActionFil
6161
* .ml-* is used by ML
6262
* .slo-observability-* is used by Observability
6363
*/
64-
private static Set<String> IGNORED_INDEX_NAMES = Set.of(
65-
".elastic-connectors-v1",
66-
".elastic-connectors-sync-jobs-v1",
67-
".ml-state",
68-
".ml-anomalies-unrelated"
69-
);
64+
private static Set<String> IGNORED_INDEX_NAMES = Set.of(".elastic-connectors-v1", ".elastic-connectors-sync-jobs-v1", ".ml-state");
7065
public static final Setting<List<String>> IGNORED_INDEX_PATTERNS_SETTING = Setting.stringListSetting(
7166
"cluster.indices.validate_ignored_dot_patterns",
7267
List.of(
68+
"\\.ml-anomalies-.*",
69+
"\\.ml-annotations-\\d+",
7370
"\\.ml-state-\\d+",
71+
"\\.ml-stats-\\d+",
7472
"\\.slo-observability\\.sli-v\\d+.*",
7573
"\\.slo-observability\\.summary-v\\d+.*",
7674
"\\.entities\\.v\\d+\\..*",

modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.settings.Settings;
1616
import org.elasticsearch.common.util.concurrent.ThreadContext;
1717
import org.elasticsearch.common.util.set.Sets;
18+
import org.elasticsearch.core.Nullable;
1819
import org.elasticsearch.test.ESTestCase;
1920
import org.elasticsearch.threadpool.ThreadPool;
2021
import org.junit.BeforeClass;
@@ -27,8 +28,8 @@
2728
import static org.mockito.Mockito.when;
2829

2930
public class DotPrefixValidatorTests extends ESTestCase {
30-
private final OperatorValidator<?> opV = new OperatorValidator<>();
31-
private final NonOperatorValidator<?> nonOpV = new NonOperatorValidator<>();
31+
private final OperatorValidator<?> opV = new OperatorValidator<>(true);
32+
private final NonOperatorValidator<?> nonOpV = new NonOperatorValidator<>(true);
3233

3334
private static ClusterService clusterService;
3435

@@ -58,14 +59,19 @@ public void testValidation() {
5859
opV.validateIndices(Set.of(".regular"));
5960
assertFails(Set.of("first", ".second"));
6061
assertFails(Set.of("<.regular-{MM-yy-dd}>"));
62+
assertFails(Set.of(".this_index_contains_an_excepted_pattern.ml-annotations-1"));
6163

6264
// Test ignored names
6365
nonOpV.validateIndices(Set.of(".elastic-connectors-v1"));
6466
nonOpV.validateIndices(Set.of(".elastic-connectors-sync-jobs-v1"));
6567
nonOpV.validateIndices(Set.of(".ml-state"));
68+
nonOpV.validateIndices(Set.of(".ml-state-000001"));
69+
nonOpV.validateIndices(Set.of(".ml-stats-000001"));
6670
nonOpV.validateIndices(Set.of(".ml-anomalies-unrelated"));
6771

6872
// Test ignored patterns
73+
nonOpV.validateIndices(Set.of(".ml-annotations-21309"));
74+
nonOpV.validateIndices(Set.of(".ml-annotations-2"));
6975
nonOpV.validateIndices(Set.of(".ml-state-21309"));
7076
nonOpV.validateIndices(Set.of("<.ml-state-21309>"));
7177
nonOpV.validateIndices(Set.of(".slo-observability.sli-v2"));
@@ -100,18 +106,22 @@ public void testValidation() {
100106
}
101107

102108
private void assertFails(Set<String> indices) {
103-
nonOpV.validateIndices(indices);
109+
var validator = new NonOperatorValidator<>(false);
110+
validator.validateIndices(indices);
104111
assertWarnings(
105112
"Index ["
106113
+ indices.stream().filter(i -> i.startsWith(".") || i.startsWith("<.")).toList().get(0)
107114
+ "] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version."
108115
);
109116
}
110117

111-
private static class NonOperatorValidator<R> extends DotPrefixValidator<R> {
118+
private class NonOperatorValidator<R> extends DotPrefixValidator<R> {
112119

113-
private NonOperatorValidator() {
120+
private final boolean assertNoWarnings;
121+
122+
private NonOperatorValidator(boolean assertNoWarnings) {
114123
super(new ThreadContext(Settings.EMPTY), clusterService);
124+
this.assertNoWarnings = assertNoWarnings;
115125
}
116126

117127
@Override
@@ -124,13 +134,25 @@ public String actionName() {
124134
return "";
125135
}
126136

137+
@Override
138+
void validateIndices(@Nullable Set<String> indices) {
139+
super.validateIndices(indices);
140+
if (assertNoWarnings) {
141+
assertWarnings();
142+
}
143+
}
144+
127145
@Override
128146
boolean isInternalRequest() {
129147
return false;
130148
}
131149
}
132150

133-
private static class OperatorValidator<R> extends NonOperatorValidator<R> {
151+
private class OperatorValidator<R> extends NonOperatorValidator<R> {
152+
private OperatorValidator(boolean assertNoWarnings) {
153+
super(assertNoWarnings);
154+
}
155+
134156
@Override
135157
boolean isInternalRequest() {
136158
return true;

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ tests:
396396
- class: org.elasticsearch.xpack.ml.integration.RevertModelSnapshotIT
397397
method: testRevertModelSnapshot_DeleteInterveningResults
398398
issue: https://github.com/elastic/elasticsearch/issues/132349
399-
#- class: org.elasticsearch.xpack.ml.integration.TextEmbeddingQueryIT
400-
# method: testHybridSearch
401-
# issue: https://github.com/elastic/elasticsearch/issues/132703
402399
- class: org.elasticsearch.xpack.ml.integration.RevertModelSnapshotIT
403400
method: testRevertModelSnapshot
404401
issue: https://github.com/elastic/elasticsearch/issues/132733
@@ -426,9 +423,6 @@ tests:
426423
- class: org.elasticsearch.xpack.search.AsyncSearchErrorTraceIT
427424
method: testAsyncSearchFailingQueryErrorTraceDefault
428425
issue: https://github.com/elastic/elasticsearch/issues/133010
429-
- class: org.elasticsearch.xpack.ml.integration.TextEmbeddingQueryIT
430-
method: testModelWithPrefixStrings
431-
issue: https://github.com/elastic/elasticsearch/issues/133138
432426
- class: org.elasticsearch.xpack.security.authc.AuthenticationServiceTests
433427
method: testInvalidToken
434428
issue: https://github.com/elastic/elasticsearch/issues/133328

0 commit comments

Comments
 (0)