Skip to content

Commit 207dfc9

Browse files
authored
[8.19] Cutover to the new transport version system (#135047)
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.
1 parent 2da39f9 commit 207dfc9

File tree

9 files changed

+29
-52
lines changed

9 files changed

+29
-52
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private void validateUpperBound(
255255
}
256256

257257
TransportVersionUpperBound existingUpperBound = getResources().get().getUpperBoundFromUpstream(upperBound.name());
258-
if (existingUpperBound != null) {
258+
if (existingUpperBound != null && getShouldValidatePrimaryIdNotPatch().get()) {
259259
if (upperBound.definitionId().patch() != 0 && upperBound.definitionId().base() != existingUpperBound.definitionId().base()) {
260260
throwUpperBoundFailure(
261261
upperBound,

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@
2121
import java.util.TreeSet;
2222

2323
/**
24-
* <p>Transport version is used to coordinate compatible wire protocol communication between nodes, at a fine-grained level. This replaces
25-
* and supersedes the old Version constants.</p>
24+
* Legacy container for transport version constants.
2625
*
27-
* <p>Before adding a new version constant, please read the block comment at the end of the list of constants.</p>
26+
* ____ ___ _ _ ___ _____ _____ ____ ___ _____ _____ _ _ ___ ____ _____ ___ _ _____
27+
* | _ \ / _ \ | \ | |/ _ \_ _| | ____| _ \_ _|_ _| |_ _| | | |_ _/ ___| | ___|_ _| | | ____|
28+
* | | | | | | | | \| | | | || | | _| | | | | | | | | | | |_| || |\___ \ | |_ | || | | _|
29+
* | |_| | |_| | | |\ | |_| || | | |___| |_| | | | | | | | _ || | ___) | | _| | || |___| |___
30+
* |____/ \___/ |_| \_|\___/ |_| |_____|____/___| |_| |_| |_| |_|___|____/ |_| |___|_____|_____|
31+
*
32+
* DO NOT EDIT THIS FILE! New transport versions should be added using the new transport version system.
33+
* See docs/internal/Versioning.md.
2834
*/
2935
public class TransportVersions {
3036

@@ -176,8 +182,6 @@ static TransportVersion def(int id) {
176182
public static final TransportVersion ML_INFERENCE_IBM_WATSONX_RERANK_ADDED = def(8_840_0_00);
177183
public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_18 = def(8_840_0_01);
178184
public static final TransportVersion RETRY_ILM_ASYNC_ACTION_REQUIRE_ERROR_8_18 = def(8_840_0_02);
179-
public static final TransportVersion INITIAL_ELASTICSEARCH_8_18_7 = def(8_840_0_09);
180-
public static final TransportVersion INITIAL_ELASTICSEARCH_8_18_8 = def(8_840_0_10);
181185
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19 = def(8_841_0_00);
182186
public static final TransportVersion COHERE_BIT_EMBEDDING_TYPE_SUPPORT_ADDED_BACKPORT_8_X = def(8_841_0_01);
183187
public static final TransportVersion REMOVE_ALL_APPLICABLE_SELECTOR_BACKPORT_8_19 = def(8_841_0_02);
@@ -241,8 +245,6 @@ static TransportVersion def(int id) {
241245
public static final TransportVersion ML_INFERENCE_COHERE_API_VERSION_8_19 = def(8_841_0_60);
242246
public static final TransportVersion ESQL_DOCUMENTS_FOUND_AND_VALUES_LOADED_8_19 = def(8_841_0_61);
243247
public static final TransportVersion ESQL_PROFILE_INCLUDE_PLAN_8_19 = def(8_841_0_62);
244-
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_4 = def(8_841_0_68);
245-
public static final TransportVersion INITIAL_ELASTICSEARCH_8_19_5 = def(8_841_0_69);
246248

247249
/*
248250
* STOP! READ THIS FIRST! No, really,
@@ -252,49 +254,9 @@ static TransportVersion def(int id) {
252254
* ___) || || |_| | __/|_| | _ <| |___ / ___ \| |_| | | | | _ || | ___) | | _| | || _ < ___) || | |_|
253255
* |____/ |_| \___/|_| (_) |_| \_\_____/_/ \_\____/ |_| |_| |_|___|____/ |_| |___|_| \_\____/ |_| (_)
254256
*
255-
* A new transport version should be added EVERY TIME a change is made to the serialization protocol of one or more classes. Each
256-
* 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).
257-
*
258-
* ADDING A TRANSPORT VERSION
259-
* To add a new transport version, add a new constant at the bottom of the list, above this comment. Don't add other lines,
260-
* comments, etc. The version id has the following layout:
261-
*
262-
* M_NNN_S_PP
263-
*
264-
* M - The major version of Elasticsearch
265-
* NNN - The server version part
266-
* S - The subsidiary version part. It should always be 0 here, it is only used in subsidiary repositories.
267-
* PP - The patch version part
268-
*
269-
* To determine the id of the next TransportVersion constant, do the following:
270-
* - Use the same major version, unless bumping majors
271-
* - Bump the server version part by 1, unless creating a patch version
272-
* - Leave the subsidiary part as 0
273-
* - Bump the patch part if creating a patch version
274-
*
275-
* If a patch version is created, it should be placed sorted among the other existing constants.
276-
*
277-
* REVERTING A TRANSPORT VERSION
278-
*
279-
* If you revert a commit with a transport version change, you MUST ensure there is a NEW transport version representing the reverted
280-
* change. DO NOT let the transport version go backwards, it must ALWAYS be incremented.
281-
*
282-
* DETERMINING TRANSPORT VERSIONS FROM GIT HISTORY
283-
*
284-
* If your git checkout has the expected minor-version-numbered branches and the expected release-version tags then you can find the
285-
* transport versions known by a particular release ...
286-
*
287-
* git show v8.11.0:server/src/main/java/org/elasticsearch/TransportVersions.java | grep '= def'
288-
*
289-
* ... or by a particular branch ...
290-
*
291-
* git show 8.11:server/src/main/java/org/elasticsearch/TransportVersions.java | grep '= def'
292-
*
293-
* ... and you can see which versions were added in between two versions too ...
294-
*
295-
* git diff v8.11.0..main -- server/src/main/java/org/elasticsearch/TransportVersions.java
257+
* DO NOT EDIT THIS FILE.
296258
*
297-
* In branches 8.7-8.10 see server/src/main/java/org/elasticsearch/TransportVersion.java for the equivalent definitions.
259+
* Transport version must now be added with the new transport version system. See docs/internal/Versioning.md
298260
*/
299261

300262
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8840009
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8840010
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8841068
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8841069
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
initial_elasticsearch_8_18_6,8840008
1+
initial_elasticsearch_8_18_8,8840010
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
initial_elasticsearch_8_19_3,8841067
1+
initial_elasticsearch_8_19_5,8841069

server/src/test/java/org/elasticsearch/TransportVersionTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static org.hamcrest.Matchers.contains;
2828
import static org.hamcrest.Matchers.containsString;
2929
import static org.hamcrest.Matchers.endsWith;
30+
import static org.hamcrest.Matchers.equalTo;
3031
import static org.hamcrest.Matchers.greaterThan;
3132
import static org.hamcrest.Matchers.is;
3233
import static org.hamcrest.Matchers.lessThan;
@@ -459,4 +460,14 @@ public void testMoreLikeThis() {
459460
)
460461
);
461462
}
463+
464+
public void testTransportVersionsLocked() {
465+
List<TransportVersion> versions = TransportVersions.DEFINED_VERSIONS;
466+
assertThat(
467+
"TransportVersions.java is locked. Generate transport versions with TransportVersion.fromName "
468+
+ "and generateTransportVersion gradle task",
469+
versions.get(versions.size() - 1).id(),
470+
equalTo(8_841_0_62)
471+
);
472+
}
462473
}

0 commit comments

Comments
 (0)