From dad595c0cf141f8f071412e90b135500793124f0 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Thu, 6 Mar 2025 11:25:30 +0000 Subject: [PATCH 1/2] Remove 7.17 transport versions --- .../org/elasticsearch/TransportVersions.java | 3 -- .../TransportNodesListShardStoreMetadata.java | 3 -- .../bucket/range/InternalBinaryRange.java | 10 ++--- .../bucket/range/InternalRange.java | 44 +++++++------------ .../bucket/range/RangeAggregator.java | 11 ++--- .../transforms/TransformTaskParams.java | 2 +- .../user/GetUserPrivilegesResponseTests.java | 2 +- .../AuthenticationSerializationTests.java | 2 +- .../security/authc/AuthenticationTests.java | 4 +- .../security/authz/RoleDescriptorTests.java | 8 ++-- .../xpack/eql/action/EqlSearchRequest.java | 8 +--- .../eql/action/EqlSearchRequestTests.java | 2 +- ...curityServerTransportInterceptorTests.java | 2 +- 13 files changed, 36 insertions(+), 65 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 4c031b963e242..7441a4687cfca 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -66,9 +66,6 @@ static TransportVersion def(int id) { public static final TransportVersion V_7_15_0 = def(7_15_00_99); public static final TransportVersion V_7_15_1 = def(7_15_01_99); public static final TransportVersion V_7_16_0 = def(7_16_00_99); - public static final TransportVersion V_7_17_0 = def(7_17_00_99); - public static final TransportVersion V_7_17_1 = def(7_17_01_99); - public static final TransportVersion V_7_17_8 = def(7_17_08_99); public static final TransportVersion V_8_0_0 = def(8_00_00_99); public static final TransportVersion V_8_1_0 = def(8_01_00_99); public static final TransportVersion V_8_2_0 = def(8_02_00_99); diff --git a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java index 8ba17aec26ce7..593442adeebc6 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -221,9 +221,6 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().before(TransportVersions.V_8_2_0)) { // no compatible version cares about the shard ID, we can just make one up FAKE_SHARD_ID.writeTo(out); - - // NB only checked this for versions back to 7.17.0, we are assuming that we don't use this with earlier versions: - assert out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) : out.getTransportVersion(); } metadataSnapshot.writeTo(out); out.writeCollection(peerRecoveryRetentionLeases); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java index 740d53eb245e4..3744724431754 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalBinaryRange.java @@ -58,11 +58,9 @@ private static String generateKey(BytesRef from, BytesRef to, DocValueFormat for } private static Bucket createFromStream(StreamInput in, DocValueFormat format) throws IOException { - // NOTE: the key is required in version == 8.0.0 and version <= 7.17.0, + // NOTE: the key is required in version == 8.0.0, // while it is optional for all subsequent versions. - String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() - : in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1) ? in.readOptionalString() - : in.readString(); + String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() : in.readOptionalString(); BytesRef from = in.readOptional(StreamInput::readBytesRef); BytesRef to = in.readOptional(StreamInput::readBytesRef); long docCount = in.readLong(); @@ -75,10 +73,8 @@ private static Bucket createFromStream(StreamInput in, DocValueFormat format) th public void writeTo(StreamOutput out) throws IOException { if (out.getTransportVersion().equals(TransportVersions.V_8_0_0)) { out.writeString(key == null ? generateKey(from, to, format) : key); - } else if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1)) { - out.writeOptionalString(key); } else { - out.writeString(key == null ? generateKey(from, to, format) : key); + out.writeOptionalString(key); } out.writeOptional(StreamOutput::writeBytesRef, from); out.writeOptional(StreamOutput::writeBytesRef, to); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index 1d28da5801b8a..35a72ac676363 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -138,23 +138,17 @@ private static String generateKey(double from, double to, DocValueFormat format) @Override public void writeTo(StreamOutput out) throws IOException { - // NOTE: the key is required in version == 8.0.0 and version <= 7.17.0, + // NOTE: the key is required in version == 8.0.0, // while it is optional for all subsequent versions. if (out.getTransportVersion().equals(TransportVersions.V_8_0_0)) { out.writeString(key == null ? generateKey(from, to, format) : key); - } else if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1)) { - out.writeOptionalString(key); } else { - out.writeString(key == null ? generateKey(from, to, format) : key); + out.writeOptionalString(key); } out.writeDouble(from); - if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) { - out.writeOptionalDouble(from); - } + out.writeOptionalDouble(from); out.writeDouble(to); - if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) { - out.writeOptionalDouble(to); - } + out.writeOptionalDouble(to); out.writeVLong(docCount); aggregations.writeTo(out); } @@ -236,28 +230,22 @@ public InternalRange(StreamInput in) throws IOException { int size = in.readVInt(); List ranges = new ArrayList<>(size); for (int i = 0; i < size; i++) { - // NOTE: the key is required in version == 8.0.0 and version <= 7.17.0, + // NOTE: the key is required in version == 8.0.0, // while it is optional for all subsequent versions. - final String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() - : in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_1) ? in.readOptionalString() - : in.readString(); + final String key = in.getTransportVersion().equals(TransportVersions.V_8_0_0) ? in.readString() : in.readOptionalString(); double from = in.readDouble(); - if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) { - final Double originalFrom = in.readOptionalDouble(); - if (originalFrom != null) { - from = originalFrom; - } else { - from = Double.NEGATIVE_INFINITY; - } + final Double originalFrom = in.readOptionalDouble(); + if (originalFrom != null) { + from = originalFrom; + } else { + from = Double.NEGATIVE_INFINITY; } double to = in.readDouble(); - if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) { - final Double originalTo = in.readOptionalDouble(); - if (originalTo != null) { - to = originalTo; - } else { - to = Double.POSITIVE_INFINITY; - } + final Double originalTo = in.readOptionalDouble(); + if (originalTo != null) { + to = originalTo; + } else { + to = Double.POSITIVE_INFINITY; } long docCount = in.readVLong(); InternalAggregations aggregations = InternalAggregations.readFrom(in); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java index a4574e8081868..860b272699b79 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java @@ -10,7 +10,6 @@ import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.ScorerSupplier; -import org.elasticsearch.TransportVersions; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -176,8 +175,8 @@ public Range(StreamInput in) throws IOException { toAsStr = in.readOptionalString(); from = in.readDouble(); to = in.readDouble(); - originalFrom = in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) ? in.readOptionalDouble() : Double.valueOf(from); - originalTo = in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0) ? in.readOptionalDouble() : Double.valueOf(to); + originalFrom = in.readOptionalDouble(); + originalTo = in.readOptionalDouble(); } @Override @@ -187,10 +186,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(toAsStr); out.writeDouble(from); out.writeDouble(to); - if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_0)) { - out.writeOptionalDouble(originalFrom); - out.writeOptionalDouble(originalTo); - } + out.writeOptionalDouble(originalFrom); + out.writeOptionalDouble(originalTo); } public double getFrom() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParams.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParams.java index 9b49b58b0d6ec..fd48fc9ef4c20 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParams.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformTaskParams.java @@ -93,7 +93,7 @@ public String getWriteableName() { @Override public TransportVersion getMinimalSupportedVersion() { - return TransportVersions.V_7_17_0; + return TransportVersions.ZERO; } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java index ab62073c12d80..73e12fe2625c3 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java @@ -92,7 +92,7 @@ public void testSerializationWithRemoteIndicesThrowsOnUnsupportedVersions() thro ); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeAdvancedRemoteClusterSecurity ); out.setTransportVersion(version); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java index d9d235c8ce41b..b7c7681c95d03 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java @@ -89,7 +89,7 @@ public void testWriteToWithCrossClusterAccessThrowsOnUnsupportedVersion() throws final BytesStreamOutput out = new BytesStreamOutput(); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, TransportVersionUtils.getPreviousVersion(RemoteClusterPortSettings.TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY) ); out.setTransportVersion(version); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java index a485c495b5583..0ab13ed008ba2 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java @@ -853,7 +853,7 @@ public void testMaybeRewriteForOlderVersionWithCrossClusterAccessThrowsOnUnsuppo ); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, // the minimum compatible version of 8.x + TransportVersions.V_8_0_0, versionBeforeCrossClusterAccessRealm ); @@ -958,7 +958,7 @@ public void testCopyWithFilteredMetadataFields() { public void testMaybeRewriteForOlderVersionErasesDomainForVersionsBeforeDomains() { final TransportVersion olderVersion = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, TransportVersionUtils.getPreviousVersion(Authentication.VERSION_REALM_DOMAINS) ); final Authentication authentication = AuthenticationTestHelper.builder() diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java index 3ca6777512420..b15ab80ba6c2e 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/RoleDescriptorTests.java @@ -651,7 +651,7 @@ public void testSerializationWithRemoteIndicesWithElderVersion() throws IOExcept final TransportVersion versionBeforeRemoteIndices = TransportVersionUtils.getPreviousVersion(TransportVersions.V_8_8_0); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeRemoteIndices ); final BytesStreamOutput output = new BytesStreamOutput(); @@ -702,7 +702,7 @@ public void testSerializationWithRemoteClusterWithElderVersion() throws IOExcept final TransportVersion versionBeforeRemoteCluster = TransportVersionUtils.getPreviousVersion(ROLE_REMOTE_CLUSTER_PRIVS); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeRemoteCluster ); final BytesStreamOutput output = new BytesStreamOutput(); @@ -753,7 +753,7 @@ public void testSerializationWithWorkflowsRestrictionAndUnsupportedVersions() th final TransportVersion versionBeforeWorkflowsRestriction = TransportVersionUtils.getPreviousVersion(WORKFLOWS_RESTRICTION_VERSION); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeWorkflowsRestriction ); final BytesStreamOutput output = new BytesStreamOutput(); @@ -848,7 +848,7 @@ public void testSerializationWithDescriptionAndUnsupportedVersions() throws IOEx final TransportVersion versionBeforeRoleDescription = TransportVersionUtils.getPreviousVersion(SECURITY_ROLE_DESCRIPTION); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeRoleDescription ); final BytesStreamOutput output = new BytesStreamOutput(); diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java index 0b1d5005c5f89..1ebd2997098ff 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java @@ -127,9 +127,7 @@ public EqlSearchRequest(StreamInput in) throws IOException { this.waitForCompletionTimeout = in.readOptionalTimeValue(); this.keepAlive = in.readOptionalTimeValue(); this.keepOnCompletion = in.readBoolean(); - if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_17_8)) { - resultPosition = in.readString(); - } + resultPosition = in.readString(); if (in.getTransportVersion().onOrAfter(TransportVersions.V_7_13_0)) { if (in.readBoolean()) { fetchFields = in.readCollectionAsList(FieldAndFormat::new); @@ -492,9 +490,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalTimeValue(waitForCompletionTimeout); out.writeOptionalTimeValue(keepAlive); out.writeBoolean(keepOnCompletion); - if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_17_8)) { - out.writeString(resultPosition); - } + out.writeString(resultPosition); if (out.getTransportVersion().onOrAfter(TransportVersions.V_7_13_0)) { out.writeBoolean(fetchFields != null); if (fetchFields != null) { diff --git a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/EqlSearchRequestTests.java b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/EqlSearchRequestTests.java index 1a06aead910c8..4905bbb3a4502 100644 --- a/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/EqlSearchRequestTests.java +++ b/x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/action/EqlSearchRequestTests.java @@ -136,7 +136,7 @@ protected EqlSearchRequest mutateInstanceForVersion(EqlSearchRequest instance, T mutatedInstance.keepOnCompletion(instance.keepOnCompletion()); mutatedInstance.fetchFields(version.onOrAfter(TransportVersions.V_7_13_0) ? instance.fetchFields() : null); mutatedInstance.runtimeMappings(version.onOrAfter(TransportVersions.V_7_13_0) ? instance.runtimeMappings() : emptyMap()); - mutatedInstance.resultPosition(version.onOrAfter(TransportVersions.V_7_17_8) ? instance.resultPosition() : "tail"); + mutatedInstance.resultPosition(instance.resultPosition()); mutatedInstance.maxSamplesPerKey(version.onOrAfter(TransportVersions.V_8_7_0) ? instance.maxSamplesPerKey() : 1); mutatedInstance.allowPartialSearchResults( version.onOrAfter(TransportVersions.EQL_ALLOW_PARTIAL_SEARCH_RESULTS) ? instance.allowPartialSearchResults() : false diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java index 3a3ae55cad090..fb27f5ada1ef2 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/SecurityServerTransportInterceptorTests.java @@ -969,7 +969,7 @@ public void sendRequest( ); final TransportVersion version = TransportVersionUtils.randomVersionBetween( random(), - TransportVersions.V_7_17_0, + TransportVersions.V_8_0_0, versionBeforeCrossClusterAccessRealm ); when(connection.getTransportVersion()).thenReturn(version); From 5857154fc7a2c9cc2f18d2ca84499be98786da9a Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Mon, 10 Mar 2025 12:40:35 +0000 Subject: [PATCH 2/2] Fix merge --- .../org/elasticsearch/xpack/eql/action/EqlSearchRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java index ef015b4b9574f..1e923fd300f41 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/action/EqlSearchRequest.java @@ -125,6 +125,7 @@ public EqlSearchRequest(StreamInput in) throws IOException { this.waitForCompletionTimeout = in.readOptionalTimeValue(); this.keepAlive = in.readOptionalTimeValue(); this.keepOnCompletion = in.readBoolean(); + resultPosition = in.readString(); if (in.readBoolean()) { fetchFields = in.readCollectionAsList(FieldAndFormat::new); } @@ -487,7 +488,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeCollection(fetchFields); } out.writeGenericMap(runtimeMappings); - out.writeGenericMap(runtimeMappings); if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) { out.writeInt(maxSamplesPerKey); }