Skip to content

Commit 35fb7e0

Browse files
committed
Fix snapshot upgrade test (#136433)
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) # Conflicts: # muted-tests.yml # x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java
1 parent 0700241 commit 35fb7e0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.nodes().isMixedVersionCluster()) {
114114
listener.onFailure(
115115
ExceptionsHelper.conflictStatusException(
116116
"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)