Skip to content

Commit 6257be7

Browse files
authored
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
1 parent efd41a4 commit 6257be7

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ tests:
281281
- class: org.elasticsearch.xpack.profiling.action.GetStatusActionIT
282282
method: testWaitsUntilResourcesAreCreated
283283
issue: https://github.com/elastic/elasticsearch/issues/129486
284-
- class: org.elasticsearch.upgrades.MlJobSnapshotUpgradeIT
285-
method: testSnapshotUpgrader
286-
issue: https://github.com/elastic/elasticsearch/issues/98560
287284
- class: org.elasticsearch.search.query.VectorIT
288285
method: testFilteredQueryStrategy
289286
issue: https://github.com/elastic/elasticsearch/issues/129517

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
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.ElasticsearchStatusException;
1212
import org.elasticsearch.ResourceAlreadyExistsException;
1313
import org.elasticsearch.ResourceNotFoundException;
14-
import org.elasticsearch.TransportVersion;
1514
import org.elasticsearch.action.ActionListener;
1615
import org.elasticsearch.action.support.ActionFilters;
1716
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@@ -110,7 +109,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A
110109
return;
111110
}
112111

113-
if (state.getMinTransportVersion().equals(TransportVersion.current()) == 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).onOrAfter(Version.V_9_3_0)
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)