From 6cd35e17b8e561865c78f5a4ccc879e4e0664e8d Mon Sep 17 00:00:00 2001 From: Donal Evans Date: Mon, 13 Oct 2025 09:11:19 -0700 Subject: [PATCH 1/2] 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 6257be71c27baef19d4910bba47d555bc92d3b44) # Conflicts: # muted-tests.yml # x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java --- .../TransportUpgradeJobModelSnapshotAction.java | 3 +-- .../upgrades/MlJobSnapshotUpgradeIT.java | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java index c5ab84d277a0d..bebbea11fb52c 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java @@ -48,7 +48,6 @@ import org.elasticsearch.xpack.core.ml.job.results.Result; import org.elasticsearch.xpack.core.ml.job.snapshot.upgrade.SnapshotUpgradeTaskParams; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; -import org.elasticsearch.xpack.core.ml.utils.TransportVersionUtils; import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider; @@ -112,7 +111,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A return; } - if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) { + if (state.nodes().getMinNodeVersion().equals(state.nodes().getMaxNodeVersion()) == false) { listener.onFailure( ExceptionsHelper.conflictStatusException( "Cannot upgrade job [{}] snapshot [{}] while cluster upgrade is in progress.", diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java index 79f42244b37c2..4cc34b7399d9f 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java @@ -7,6 +7,7 @@ package org.elasticsearch.upgrades; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; @@ -74,6 +75,10 @@ public void testSnapshotUpgrader() throws Exception { case OLD -> createJobAndSnapshots(); case MIXED -> { assumeTrue("We should only test if old cluster is before new cluster", isOriginalClusterCurrent() == false); + assumeTrue( + "Older versions could not always reliably determine if we were in a mixed cluster state", + Version.fromString(UPGRADE_FROM_VERSION).onOrAfter(Version.V_8_18_9) + ); ensureHealth((request -> { request.addParameter("timeout", "70s"); request.addParameter("wait_for_nodes", "3"); @@ -97,13 +102,6 @@ public void testSnapshotUpgrader() throws Exception { @SuppressWarnings("unchecked") private void testSnapshotUpgradeFailsOnMixedCluster() throws Exception { - // TODO the mixed cluster assertions sometimes fail because the code that - // detects the mixed cluster relies on the transport versions being different. - // This assumption does not hold immediately after a version bump and new - // branch being cut as the new branch will have the same transport version - // See https://github.com/elastic/elasticsearch/issues/98560 - - assumeTrue("The mixed cluster is not always detected correctly, see https://github.com/elastic/elasticsearch/issues/98560", false); Map jobs = entityAsMap(getJob(JOB_ID)); String currentSnapshot = ((List) XContentMapValues.extractValue("jobs.model_snapshot_id", jobs)).get(0); From 4a3a72e3a5cd3fbbfbe691d71f99c674cca9678c Mon Sep 17 00:00:00 2001 From: donalevans Date: Mon, 13 Oct 2025 09:48:32 -0700 Subject: [PATCH 2/2] Use after(), not onOrAfter() --- .../java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java index 4cc34b7399d9f..9d4277de21471 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MlJobSnapshotUpgradeIT.java @@ -77,7 +77,7 @@ public void testSnapshotUpgrader() throws Exception { assumeTrue("We should only test if old cluster is before new cluster", isOriginalClusterCurrent() == false); assumeTrue( "Older versions could not always reliably determine if we were in a mixed cluster state", - Version.fromString(UPGRADE_FROM_VERSION).onOrAfter(Version.V_8_18_9) + Version.fromString(UPGRADE_FROM_VERSION).after(Version.V_8_18_9) ); ensureHealth((request -> { request.addParameter("timeout", "70s");