Skip to content

Commit a5849ca

Browse files
authored
Remove ML TransportVersionUtils (#136050)
ML sometimes checks whether the a cluster is in the middle of an upgrade by comparing the lowest versioned node to the current node version. TransportVersionUtils exists to simplify that check, but comparing two transport versions for equality is trivial. This commit updates the few places checking for an in progress upgrade and removes TransportVersionUtils.
1 parent 97e24d6 commit a5849ca

File tree

5 files changed

+6
-102
lines changed

5 files changed

+6
-102
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/TransportVersionUtils.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.ElasticsearchStatusException;
1515
import org.elasticsearch.ResourceAlreadyExistsException;
1616
import org.elasticsearch.ResourceNotFoundException;
17+
import org.elasticsearch.TransportVersion;
1718
import org.elasticsearch.action.ActionListener;
1819
import org.elasticsearch.action.search.SearchResponse;
1920
import org.elasticsearch.action.support.ActionFilters;
@@ -64,7 +65,6 @@
6465
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.IndexLocation;
6566
import org.elasticsearch.xpack.core.ml.job.messages.Messages;
6667
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
67-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
6868
import org.elasticsearch.xpack.ml.MachineLearning;
6969
import org.elasticsearch.xpack.ml.inference.assignment.TrainedModelAssignmentService;
7070
import org.elasticsearch.xpack.ml.inference.persistence.TrainedModelDefinitionDoc;
@@ -148,7 +148,7 @@ protected void masterOperation(
148148
return;
149149
}
150150

151-
if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) {
151+
if (state.getMinTransportVersion().equals(TransportVersion.current()) == false) {
152152
listener.onFailure(
153153
new ElasticsearchStatusException(
154154
"Cannot start model deployment [{}] while cluster upgrade is in progress.",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.ElasticsearchStatusException;
1212
import org.elasticsearch.ResourceAlreadyExistsException;
1313
import org.elasticsearch.ResourceNotFoundException;
14+
import org.elasticsearch.TransportVersion;
1415
import org.elasticsearch.action.ActionListener;
1516
import org.elasticsearch.action.support.ActionFilters;
1617
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@@ -47,7 +48,6 @@
4748
import org.elasticsearch.xpack.core.ml.job.results.Result;
4849
import org.elasticsearch.xpack.core.ml.job.snapshot.upgrade.SnapshotUpgradeTaskParams;
4950
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
50-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
5151
import org.elasticsearch.xpack.ml.MachineLearning;
5252
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
5353
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
@@ -110,7 +110,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
110110
return;
111111
}
112112

113-
if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) {
113+
if (state.getMinTransportVersion().equals(TransportVersion.current()) == false) {
114114
listener.onFailure(
115115
ExceptionsHelper.conflictStatusException(
116116
"Cannot upgrade job [{}] snapshot [{}] while cluster upgrade is in progress.",

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/TransportVersionUtilsTests.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpgradeTransformsAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.logging.log4j.Logger;
1212
import org.elasticsearch.ElasticsearchStatusException;
1313
import org.elasticsearch.ResourceNotFoundException;
14+
import org.elasticsearch.TransportVersion;
1415
import org.elasticsearch.action.ActionListener;
1516
import org.elasticsearch.action.support.ActionFilters;
1617
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@@ -29,7 +30,6 @@
2930
import org.elasticsearch.threadpool.ThreadPool;
3031
import org.elasticsearch.transport.TransportService;
3132
import org.elasticsearch.xpack.core.XPackSettings;
32-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
3333
import org.elasticsearch.xpack.core.security.SecurityContext;
3434
import org.elasticsearch.xpack.core.transform.TransformMetadata;
3535
import org.elasticsearch.xpack.core.transform.action.UpgradeTransformsAction;
@@ -107,7 +107,7 @@ protected void masterOperation(Task ignoredTask, Request request, ClusterState s
107107
}
108108

109109
// do not allow in mixed clusters
110-
if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) {
110+
if (state.getMinTransportVersion().equals(TransportVersion.current()) == false) {
111111
listener.onFailure(
112112
new ElasticsearchStatusException("Cannot upgrade transforms while cluster upgrade is in progress.", RestStatus.CONFLICT)
113113
);

0 commit comments

Comments
 (0)