Skip to content

Commit 71d54f4

Browse files
authored
[9.0] Fix snapshot upgrade test (elastic#136433) (elastic#136496)
Using transport version to determine if a cluster is mixed version is sometimes unreliable, so use DiscoveryNodes versions instead Closes elastic#98560 (cherry picked from commit 6257be7)
1 parent 91faeb6 commit 71d54f4

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
@@ -47,7 +47,6 @@
4747
import org.elasticsearch.xpack.core.ml.job.results.Result;
4848
import org.elasticsearch.xpack.core.ml.job.snapshot.upgrade.SnapshotUpgradeTaskParams;
4949
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
50-
import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils;
5150
import org.elasticsearch.xpack.ml.MachineLearning;
5251
import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider;
5352
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
@@ -110,7 +109,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
110109
return;
111110
}
112111

113-
if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) {
112+
if (state.nodes().isMixedVersionCluster()) {
114113
listener.onFailure(
115114
ExceptionsHelper.conflictStatusException(
116115
"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_9_0_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)