Skip to content

Commit 4aa02f4

Browse files
authored
[8.18] Fix snapshot upgrade test (#136499)
Using transport version to determine if a cluster is mixed version is sometimes unreliable, so use DiscoveryNodes versions instead Closes #98560 (cherry picked from commit 6257be7)
1 parent 6a8be2e commit 4aa02f4

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.elasticsearch.xpack.core.ml.job.results.Result;
4949
import org.elasticsearch.xpack.core.ml.job.snapshot.upgrade.SnapshotUpgradeTaskParams;
5050
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
51-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
5251
import org.elasticsearch.xpack.ml.MachineLearning;
5352
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
5453
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
@@ -112,7 +111,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
112111
return;
113112
}
114113

115-
if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) {
114+
if (state.nodes().getMinNodeVersion().equals(state.nodes().getMaxNodeVersion()) == false) {
116115
listener.onFailure(
117116
ExceptionsHelper.conflictStatusException(
118117
"Cannot upgrade job [{}] snapshot [{}] while cluster upgrade is in progress.",

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.elasticsearch.upgrades;
88

99
import org.elasticsearch.ElasticsearchException;
10+
import org.elasticsearch.Version;
1011
import org.elasticsearch.client.Request;
1112
import org.elasticsearch.client.RequestOptions;
1213
import org.elasticsearch.client.Response;
@@ -74,6 +75,10 @@ public void testSnapshotUpgrader() throws Exception {
7475
case OLD -> createJobAndSnapshots();
7576
case MIXED -> {
7677
assumeTrue("We should only test if old cluster is before new cluster", isOriginalClusterCurrent() == false);
78+
assumeTrue(
79+
"Older versions could not always reliably determine if we were in a mixed cluster state",
80+
Version.fromString(UPGRADE_FROM_VERSION).after(Version.V_8_18_9)
81+
);
7782
ensureHealth((request -> {
7883
request.addParameter("timeout", "70s");
7984
request.addParameter("wait_for_nodes", "3");
@@ -97,13 +102,6 @@ public void testSnapshotUpgrader() throws Exception {
97102

98103
@SuppressWarnings("unchecked")
99104
private void testSnapshotUpgradeFailsOnMixedCluster() throws Exception {
100-
// TODO the mixed cluster assertions sometimes fail because the code that
101-
// detects the mixed cluster relies on the transport versions being different.
102-
// This assumption does not hold immediately after a version bump and new
103-
// branch being cut as the new branch will have the same transport version
104-
// See https://github.com/elastic/elasticsearch/issues/98560
105-
106-
assumeTrue("The mixed cluster is not always detected correctly, see https://github.com/elastic/elasticsearch/issues/98560", false);
107105
Map<String, Object> jobs = entityAsMap(getJob(JOB_ID));
108106

109107
String currentSnapshot = ((List<String>) XContentMapValues.extractValue("jobs.model_snapshot_id", jobs)).get(0);

0 commit comments

Comments
 (0)