Преглед изворни кода

[9.1] Cutover to the new transport version system (#135045)

This commit updates the latest transport version ids to use the new
gradle managed system. It also adds a test to ensure new constants are
not added to TransportVersions.java.
Ryan Ernst пре 2 недеља
родитељ
комит
8a8e816771

+ 1 - 1
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/ValidateTransportVersionResourcesTask.java

@@ -237,7 +237,7 @@ public abstract class ValidateTransportVersionResourcesTask extends DefaultTask
         }
 
         TransportVersionUpperBound existingUpperBound = getResources().get().getUpperBoundFromUpstream(upperBound.name());
-        if (existingUpperBound != null) {
+        if (existingUpperBound != null && getShouldValidatePrimaryIdNotPatch().get()) {
             if (upperBound.definitionId().patch() != 0 && upperBound.definitionId().base() != existingUpperBound.definitionId().base()) {
                 throwUpperBoundFailure(
                     upperBound,

+ 11 - 55
server/src/main/java/org/elasticsearch/TransportVersions.java

@@ -20,10 +20,16 @@ import java.util.Map;
 import java.util.TreeSet;
 
 /**
- * <p>Transport version is used to coordinate compatible wire protocol communication between nodes, at a fine-grained level.  This replaces
- * and supersedes the old Version constants.</p>
+ * Legacy container for transport version constants.
  *
- * <p>Before adding a new version constant, please read the block comment at the end of the list of constants.</p>
+ *   ____   ___    _   _  ___ _____   _____ ____ ___ _____   _____ _   _ ___ ____    _____ ___ _     _____
+ *  |  _ \ / _ \  | \ | |/ _ \_   _| | ____|  _ \_ _|_   _| |_   _| | | |_ _/ ___|  |  ___|_ _| |   | ____|
+ *  | | | | | | | |  \| | | | || |   |  _| | | | | |  | |     | | | |_| || |\___ \  | |_   | || |   |  _|
+ *  | |_| | |_| | | |\  | |_| || |   | |___| |_| | |  | |     | | |  _  || | ___) | |  _|  | || |___| |___
+ *  |____/ \___/  |_| \_|\___/ |_|   |_____|____/___| |_|     |_| |_| |_|___|____/  |_|   |___|_____|_____|
+ *
+ * DO NOT EDIT THIS FILE! New transport versions should be added using the new transport version system.
+ * See docs/internal/Versioning.md.
  */
 public class TransportVersions {
 
@@ -136,8 +142,6 @@ public class TransportVersions {
     public static final TransportVersion ML_INFERENCE_IBM_WATSONX_RERANK_ADDED = def(8_840_0_00);
     public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_18 = def(8_840_0_01);
     public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18 = def(8_840_0_02);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_8_18_7 = def(8_840_0_09);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_8_18_8 = def(8_840_0_10);
     public static final TransportVersion INITIAL_ELASTICSEARCH_8_19 = def(8_841_0_00);
     public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_X = def(8_841_0_01);
     public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_19 = def(8_841_0_02);
@@ -200,8 +204,6 @@ public class TransportVersions {
     public static final TransportVersion ML_INFERENCE_COHERE_API_VERSION_8_19 = def(8_841_0_60);
     public static final TransportVersion ESQL_DOCUMENTS_FOUND_AND_VALUES_LOADED_8_19 = def(8_841_0_61);
     public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN_8_19 = def(8_841_0_62);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_4 = def(8_841_0_68);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_5 = def(8_841_0_69);
     public static final TransportVersion INITIAL_ELASTICSEARCH_9_0 = def(9_000_0_00);
     public static final TransportVersion REMOVE_SNAPSHOT_FAILURES_90 = def(9_000_0_01);
     public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED_90 = def(9_000_0_02);
@@ -212,8 +214,6 @@ public class TransportVersions {
     public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_90 = def(9_000_0_07);
     public static final TransportVersion RE_REMOVE_MIN_COMPATIBLE_SHARD_NODE_90 = def(9_000_0_08);
     public static final TransportVersion STORED_SCRIPT_CONTENT_LENGTH_90 = def(9_000_0_09);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_7 = def(9_000_0_16);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_8 = def(9_000_0_17);
     public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED = def(9_001_0_00);
     public static final TransportVersion REMOVE_SNAPSHOT_FAILURES = def(9_002_0_00);
     public static final TransportVersion TRANSPORT_STATS_HANDLING_TIME_REQUIRED = def(9_003_0_00);
@@ -324,8 +324,6 @@ public class TransportVersions {
     public static final TransportVersion ML_INFERENCE_ELASTIC_DENSE_TEXT_EMBEDDINGS_ADDED = def(9_109_00_0);
     public static final TransportVersion ML_INFERENCE_COHERE_API_VERSION = def(9_110_0_00);
     public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN = def(9_111_0_00);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_4 = def(9_112_0_07);
-    public static final TransportVersion INITIAL_ELASTICSEARCH_9_1_5 = def(9_112_0_08);
 
     /*
      * STOP! READ THIS FIRST! No, really,
@@ -335,51 +333,9 @@ public class TransportVersions {
      *        ___) || || |_| |  __/|_|      |  _ <| |___ / ___ \| |_| |   | | |  _  || | ___) | |  _|  | ||  _ < ___) || | |_|
      *       |____/ |_| \___/|_|   (_)      |_| \_\_____/_/   \_\____/    |_| |_| |_|___|____/  |_|   |___|_| \_\____/ |_| (_)
      *
-     * A new transport version should be added EVERY TIME a change is made to the serialization protocol of one or more classes. Each
-     * transport version should only be used in a single merged commit (apart from the BwC versions copied from o.e.Version, ≤V_8_8_1).
-     *
-     * More information about versions and backporting at docs/internal/Versioning.md
-     *
-     * ADDING A TRANSPORT VERSION
-     * To add a new transport version, add a new constant at the bottom of the list, above this comment. Don't add other lines,
-     * comments, etc. The version id has the following layout:
-     *
-     * M_NNN_S_PP
-     *
-     * M - The major version of Elasticsearch
-     * NNN - The server version part
-     * S - The subsidiary version part. It should always be 0 here, it is only used in subsidiary repositories.
-     * PP - The patch version part
-     *
-     * To determine the id of the next TransportVersion constant, do the following:
-     * - Use the same major version, unless bumping majors
-     * - Bump the server version part by 1, unless creating a patch version
-     * - Leave the subsidiary part as 0
-     * - Bump the patch part if creating a patch version
-     *
-     * If a patch version is created, it should be placed sorted among the other existing constants.
-     *
-     * REVERTING A TRANSPORT VERSION
-     *
-     * If you revert a commit with a transport version change, you MUST ensure there is a NEW transport version representing the reverted
-     * change. DO NOT let the transport version go backwards, it must ALWAYS be incremented.
-     *
-     * DETERMINING TRANSPORT VERSIONS FROM GIT HISTORY
-     *
-     * If your git checkout has the expected minor-version-numbered branches and the expected release-version tags then you can find the
-     * transport versions known by a particular release ...
-     *
-     *     git show v8.11.0:server/src/main/java/org/elasticsearch/TransportVersions.java | grep '= def'
-     *
-     * ... or by a particular branch ...
-     *
-     *     git show 8.11:server/src/main/java/org/elasticsearch/TransportVersions.java | grep '= def'
-     *
-     * ... and you can see which versions were added in between two versions too ...
-     *
-     *     git diff v8.11.0..main -- server/src/main/java/org/elasticsearch/TransportVersions.java
+     * DO NOT EDIT THIS FILE.
      *
-     * In branches 8.7-8.10 see server/src/main/java/org/elasticsearch/TransportVersion.java for the equivalent definitions.
+     * Transport version must now be added with the new transport version system. See docs/internal/Versioning.md
      */
 
     /**

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_8_18_7.csv

@@ -0,0 +1 @@
+8840009

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_8_18_8.csv

@@ -0,0 +1 @@
+8840010

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_8_19_4.csv

@@ -0,0 +1 @@
+8841068

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_8_19_5.csv

@@ -0,0 +1 @@
+8841069

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_9_0_7.csv

@@ -0,0 +1 @@
+9000016

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_9_0_8.csv

@@ -0,0 +1 @@
+9000017

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_9_1_4.csv

@@ -0,0 +1 @@
+9112007

+ 1 - 0
server/src/main/resources/transport/definitions/unreferable/initial_elasticsearch_9_1_5.csv

@@ -0,0 +1 @@
+9112008

+ 1 - 1
server/src/main/resources/transport/upper_bounds/8.18.csv

@@ -1 +1 @@
-initial_elasticsearch_8_18_6,8840008
+initial_elasticsearch_8_18_8,8840010

+ 1 - 1
server/src/main/resources/transport/upper_bounds/8.19.csv

@@ -1 +1 @@
-initial_elasticsearch_8_19_3,8841067
+initial_elasticsearch_8_19_5,8841069

+ 1 - 1
server/src/main/resources/transport/upper_bounds/9.0.csv

@@ -1 +1 @@
-initial_elasticsearch_9_0_6,9000015
+initial_elasticsearch_9_0_8,9000017

+ 1 - 1
server/src/main/resources/transport/upper_bounds/9.1.csv

@@ -1 +1 @@
-initial_elasticsearch_9_1_3,9112006
+initial_elasticsearch_9_1_5,9112008

+ 10 - 0
server/src/test/java/org/elasticsearch/TransportVersionTests.java

@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.endsWith;
+import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.lessThan;
@@ -412,4 +413,13 @@ public class TransportVersionTests extends ESTestCase {
             )
         );
     }
+
+    public void testTransportVersionsLocked() {
+        assertThat(
+            "TransportVersions.java is locked. Generate transport versions with TransportVersion.fromName "
+                + "and generateTransportVersion gradle task",
+            TransportVersions.DEFINED_VERSIONS.getLast().id(),
+            equalTo(9_111_0_00)
+        );
+    }
 }