From 35fb7e073231a688758cb629b0ff528c24a9807e 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 | 2 +- .../upgrades/MlJobSnapshotUpgradeIT.java | 12 +++++------- 2 files changed, 6 insertions(+), 8 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 e81942d0b4b95..a1efef4c35567 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 @@ -110,7 +110,7 @@ protected void masterOperation(Task task, Request request, ClusterState state, A return; } - if (TransportVersionUtils.isMinTransportVersionSameAsCurrent(state) == false) { + if (state.nodes().isMixedVersionCluster()) { 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 9cbd6ff6296a9..db99878817e70 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).after(Version.V_9_0_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 83983db0b580e785d8f46656ce8b8dd79918afd6 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Mon, 13 Oct 2025 16:41:09 +0000 Subject: [PATCH 2/2] [CI] Auto commit changes from spotless --- .../xpack/ml/action/TransportUpgradeJobModelSnapshotAction.java | 1 - 1 file changed, 1 deletion(-) 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 a1efef4c35567..99a1f0e6485c7 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 @@ -47,7 +47,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;