Skip to content

Commit c9b9eb1

Browse files
authored
[ML] Fix mixed cluster tests where nodes action is not available (#137456)
1 parent 4e68ecc commit c9b9eb1

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

muted-tests.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -426,27 +426,12 @@ tests:
426426
- class: org.elasticsearch.xpack.ml.integration.BasicDistributedJobsIT
427427
method: testFailOverBasics
428428
issue: https://github.com/elastic/elasticsearch/issues/136778
429-
- class: org.elasticsearch.xpack.inference.qa.mixed.CohereServiceMixedIT
430-
method: testRerank
431-
issue: https://github.com/elastic/elasticsearch/issues/136872
432-
- class: org.elasticsearch.xpack.inference.qa.mixed.CohereServiceMixedIT
433-
method: testCohereEmbeddings
434-
issue: https://github.com/elastic/elasticsearch/issues/136779
435429
- class: org.elasticsearch.xpack.search.CrossClusterAsyncSearchIT
436430
method: testRemoteClusterOnlyCCSWithFailuresOnAllShards
437431
issue: https://github.com/elastic/elasticsearch/issues/136894
438-
- class: org.elasticsearch.xpack.esql.qa.mixed.FieldExtractorIT
439-
method: testTextFieldWithIpSubfieldMalformed {STORED}
440-
issue: https://github.com/elastic/elasticsearch/issues/136917
441-
- class: org.elasticsearch.xpack.esql.qa.mixed.FieldExtractorIT
442-
method: testTextFieldWithKeywordSubfield {STORED}
443-
issue: https://github.com/elastic/elasticsearch/issues/136918
444432
- class: org.elasticsearch.xpack.esql.optimizer.rules.logical.HoistRemoteEnrichTopNTests
445433
method: testTopNSortExpressionWithinRemoteEnrichAliasing
446434
issue: https://github.com/elastic/elasticsearch/issues/136957
447-
- class: org.elasticsearch.xpack.esql.qa.mixed.FieldExtractorIT
448-
method: testByteFieldWithIntSubfieldTooBig {NONE}
449-
issue: https://github.com/elastic/elasticsearch/issues/137034
450435
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeMetricsIT
451436
method: test
452437
issue: https://github.com/elastic/elasticsearch/issues/137071

x-pack/plugin/ml/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
opens org.elasticsearch.xpack.ml to org.elasticsearch.painless.spi; // whitelist resource access
3333
opens org.elasticsearch.xpack.ml.utils; // for exact.properties access
3434

35+
provides org.elasticsearch.features.FeatureSpecification with org.elasticsearch.xpack.ml.MachineLearningFeatures;
3536
provides org.elasticsearch.painless.spi.PainlessExtension with org.elasticsearch.xpack.ml.MachineLearningPainlessExtension;
3637
provides org.elasticsearch.xpack.autoscaling.AutoscalingExtension with org.elasticsearch.xpack.ml.autoscaling.MlAutoscalingExtension;
3738

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.ml;
9+
10+
import org.elasticsearch.features.FeatureSpecification;
11+
import org.elasticsearch.features.NodeFeature;
12+
13+
import java.util.Set;
14+
15+
public class MachineLearningFeatures implements FeatureSpecification {
16+
17+
public static final NodeFeature COMPONENTS_RESET_ACTION = new NodeFeature("ml.components.reset");
18+
19+
public Set<NodeFeature> getFeatures() {
20+
return Set.of(COMPONENTS_RESET_ACTION);
21+
}
22+
}

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportResetMlComponentsAction.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77

88
package org.elasticsearch.xpack.ml.action;
99

10+
import org.elasticsearch.action.ActionListener;
1011
import org.elasticsearch.action.FailedNodeException;
1112
import org.elasticsearch.action.support.ActionFilters;
1213
import org.elasticsearch.action.support.nodes.TransportNodesAction;
1314
import org.elasticsearch.cluster.node.DiscoveryNode;
1415
import org.elasticsearch.cluster.service.ClusterService;
1516
import org.elasticsearch.common.io.stream.StreamInput;
17+
import org.elasticsearch.features.FeatureService;
1618
import org.elasticsearch.injection.guice.Inject;
1719
import org.elasticsearch.tasks.Task;
1820
import org.elasticsearch.threadpool.ThreadPool;
1921
import org.elasticsearch.transport.TransportService;
2022
import org.elasticsearch.xpack.core.ml.action.ResetMlComponentsAction;
23+
import org.elasticsearch.xpack.ml.MachineLearningFeatures;
2124
import org.elasticsearch.xpack.ml.inference.TrainedModelStatsService;
2225
import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
2326
import org.elasticsearch.xpack.ml.notifications.DataFrameAnalyticsAuditor;
@@ -37,6 +40,7 @@ public class TransportResetMlComponentsAction extends TransportNodesAction<
3740
private final DataFrameAnalyticsAuditor dfaAuditor;
3841
private final InferenceAuditor inferenceAuditor;
3942
private final TrainedModelStatsService trainedModelStatsService;
43+
private final FeatureService featureService;
4044

4145
@Inject
4246
public TransportResetMlComponentsAction(
@@ -47,7 +51,8 @@ public TransportResetMlComponentsAction(
4751
AnomalyDetectionAuditor anomalyDetectionAuditor,
4852
DataFrameAnalyticsAuditor dfaAuditor,
4953
InferenceAuditor inferenceAuditor,
50-
TrainedModelStatsService trainedModelStatsService
54+
TrainedModelStatsService trainedModelStatsService,
55+
FeatureService featureService
5156
) {
5257
super(
5358
ResetMlComponentsAction.NAME,
@@ -61,6 +66,20 @@ public TransportResetMlComponentsAction(
6166
this.dfaAuditor = dfaAuditor;
6267
this.inferenceAuditor = inferenceAuditor;
6368
this.trainedModelStatsService = trainedModelStatsService;
69+
this.featureService = featureService;
70+
}
71+
72+
@Override
73+
protected void doExecute(
74+
Task task,
75+
ResetMlComponentsAction.Request request,
76+
ActionListener<ResetMlComponentsAction.Response> listener
77+
) {
78+
if (featureService.clusterHasFeature(clusterService.state(), MachineLearningFeatures.COMPONENTS_RESET_ACTION) == false) {
79+
listener.onResponse(new ResetMlComponentsAction.Response(clusterService.getClusterName(), List.of(), List.of()));
80+
} else {
81+
super.doExecute(task, request, listener);
82+
}
6483
}
6584

6685
@Override

0 commit comments

Comments
 (0)