diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index 8aafb3b494b7c..726de3ed9a0e4 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -40,10 +40,8 @@ GET / "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "{lucene_version}", - "index_version" : "67890", "minimum_wire_compatibility_version" : "1.2.3", - "minimum_index_compatibility_version" : "1.2.3", - "transport_version" : "12345" + "minimum_index_compatibility_version" : "1.2.3" }, "tagline" : "You Know, for Search" } @@ -56,6 +54,4 @@ GET / // TESTRESPONSE[s/"build_snapshot" : false,/"build_snapshot" : $body.version.build_snapshot,/] // TESTRESPONSE[s/"minimum_wire_compatibility_version" : "1.2.3"/"minimum_wire_compatibility_version" : $body.version.minimum_wire_compatibility_version/] // TESTRESPONSE[s/"minimum_index_compatibility_version" : "1.2.3"/"minimum_index_compatibility_version" : $body.version.minimum_index_compatibility_version/] -// TESTRESPONSE[s/"transport_version" : "12345"/"transport_version" : $body.version.transport_version/] -// TESTRESPONSE[s/"index_version" : "67890"/"index_version" : $body.version.index_version/] // So much s/// but at least we test that the layout is close to matching.... diff --git a/modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainResponse.java b/modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainResponse.java index f5845c85253b7..3abc5d4af855f 100644 --- a/modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainResponse.java +++ b/modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainResponse.java @@ -29,8 +29,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject { private String nodeName; private Version version; - private IndexVersion indexVersion; - private TransportVersion transportVersion; + private String luceneVersion; private ClusterName clusterName; private String clusterUuid; private Build build; @@ -41,26 +40,35 @@ public class MainResponse extends ActionResponse implements ToXContentObject { super(in); nodeName = in.readString(); version = Version.readVersion(in); - indexVersion = in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031) ? IndexVersion.readVersion(in) : null; - transportVersion = in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019) ? TransportVersion.readVersion(in) : null; + + // Index version and transport version were briefly included in the main response, but + // removed before the 8.9.0 release. Reading code remains here (throwing away the values) + // for those versions until the new format has propagated through serverless. Additionally, + // the lucene version was previously read by inferring from either Version or IndexVersion. + // Now the lucene version is read explicitly. + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_037)) { + luceneVersion = in.readString(); + } else { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) { + luceneVersion = IndexVersion.readVersion(in).luceneVersion().toString(); + } else if (version.before(Version.V_8_10_0)) { + luceneVersion = IndexVersion.fromId(version.id).luceneVersion().toString(); + } else { + luceneVersion = "unknown"; + } + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) { + TransportVersion.readVersion(in); + } + } clusterName = new ClusterName(in); clusterUuid = in.readString(); build = Build.readBuild(in); } - public MainResponse( - String nodeName, - Version version, - IndexVersion indexVersion, - TransportVersion transportVersion, - ClusterName clusterName, - String clusterUuid, - Build build - ) { + public MainResponse(String nodeName, Version version, String luceneVersion, ClusterName clusterName, String clusterUuid, Build build) { this.nodeName = nodeName; this.version = version; - this.indexVersion = indexVersion; - this.transportVersion = transportVersion; + this.luceneVersion = luceneVersion; this.clusterName = clusterName; this.clusterUuid = clusterUuid; this.build = build; @@ -74,12 +82,8 @@ public Version getVersion() { return version; } - public IndexVersion getIndexVersion() { - return indexVersion; - } - - public TransportVersion getTransportVersion() { - return transportVersion; + public String getLuceneVersion() { + return luceneVersion; } public ClusterName getClusterName() { @@ -98,27 +102,27 @@ public Build getBuild() { public void writeTo(StreamOutput out) throws IOException { out.writeString(nodeName); Version.writeVersion(version, out); - if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) { - IndexVersion.writeVersion(indexVersion, out); - } - if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) { - TransportVersion.writeVersion(transportVersion, out); + + // Index version and transport version were briefly included in the main response, but + // removed before the 8.9.0 release. Writing code remains here (writing the latest versions) + // for those versions until the new format has propagated through serverless. Additionally, + // the lucene version was previously inferred from either Version or IndexVersion. + // Now the lucene version is written explicitly. + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_037)) { + out.writeString(luceneVersion); + } else { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_031)) { + IndexVersion.writeVersion(IndexVersion.current(), out); + } + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_019)) { + TransportVersion.writeVersion(TransportVersion.current(), out); + } } clusterName.writeTo(out); out.writeString(clusterUuid); Build.writeBuild(build, out); } - private String getLuceneVersion() { - if (indexVersion != null) { - return indexVersion.luceneVersion().toString(); - } else if (version.before(Version.V_8_10_0)) { - return IndexVersion.fromId(version.id).luceneVersion().toString(); - } else { - return "unknown"; - } - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); @@ -132,11 +136,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws .field("build_hash", build.hash()) .field("build_date", build.date()) .field("build_snapshot", build.isSnapshot()) - .field("lucene_version", getLuceneVersion()) - .field("index_version", indexVersion != null ? indexVersion.toString() : "unknown") + .field("lucene_version", luceneVersion) .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString()) .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString()) - .field("transport_version", transportVersion != null ? transportVersion.toString() : "unknown") .endObject(); builder.field("tagline", "You Know, for Search"); builder.endObject(); @@ -170,16 +172,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws response.version = Version.fromString( ((String) value.get("number")).replace("-SNAPSHOT", "").replaceFirst("-(alpha\\d+|beta\\d+|rc\\d+)", "") ); - - String indexVersion = (String) value.get("index_version"); - response.indexVersion = indexVersion != null && indexVersion.equals("unknown") == false - ? IndexVersion.fromId(Integer.parseInt(indexVersion)) - : null; - - String transportVersion = (String) value.get("transport_version"); - response.transportVersion = transportVersion != null && transportVersion.equals("unknown") == false - ? TransportVersion.fromString(transportVersion) - : null; + response.luceneVersion = ((String) value.get("lucene_version")); }, (parser, context) -> parser.map(), new ParseField("version")); } @@ -198,8 +191,7 @@ public boolean equals(Object o) { MainResponse other = (MainResponse) o; return Objects.equals(nodeName, other.nodeName) && Objects.equals(version, other.version) - && Objects.equals(indexVersion, other.indexVersion) - && Objects.equals(transportVersion, other.transportVersion) + && Objects.equals(luceneVersion, other.luceneVersion) && Objects.equals(clusterUuid, other.clusterUuid) && Objects.equals(build, other.build) && Objects.equals(clusterName, other.clusterName); @@ -207,7 +199,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(nodeName, version, indexVersion, transportVersion, clusterUuid, build, clusterName); + return Objects.hash(nodeName, version, luceneVersion, clusterUuid, build, clusterName); } @Override @@ -218,10 +210,8 @@ public String toString() { + '\'' + ", version=" + version - + ", indexVersion=" - + indexVersion - + ", transportVersion=" - + transportVersion + + ", luceneVersion=" + + luceneVersion + ", clusterName=" + clusterName + ", clusterUuid='" diff --git a/modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java b/modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java index e43ab5ec742d0..75ea0e1f7ab15 100644 --- a/modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java +++ b/modules/rest-root/src/main/java/org/elasticsearch/rest/root/TransportMainAction.java @@ -9,7 +9,6 @@ package org.elasticsearch.rest.root; import org.elasticsearch.Build; -import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; @@ -47,8 +46,7 @@ protected void doExecute(Task task, MainRequest request, ActionListener clusterUuid = clusterUuid + randomAlphaOfLength(5); case 1 -> nodeName = nodeName + randomAlphaOfLength(5); case 2 -> @@ -129,9 +122,11 @@ protected MainResponse mutateInstance(MainResponse mutateInstance) { build = new Build(Build.Type.UNKNOWN, build.hash(), build.date(), build.isSnapshot() == false, build.qualifiedVersion()); case 3 -> version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random())); case 4 -> clusterName = new ClusterName(clusterName + randomAlphaOfLength(5)); - case 5 -> transportVersion = randomValueOtherThan(transportVersion, () -> TransportVersionUtils.randomVersion(random())); - case 6 -> indexVersion = randomValueOtherThan(indexVersion, () -> IndexVersionUtils.randomVersion(random())); + case 5 -> luceneVersion = randomValueOtherThan( + luceneVersion, + () -> IndexVersionUtils.randomVersion(random()).luceneVersion().toString() + ); } - return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build); + return new MainResponse(nodeName, version, luceneVersion, clusterName, clusterUuid, build); } } diff --git a/modules/rest-root/src/test/java/org/elasticsearch/rest/root/RestMainActionTests.java b/modules/rest-root/src/test/java/org/elasticsearch/rest/root/RestMainActionTests.java index 49de15e445f75..7b2e0f3107b8d 100644 --- a/modules/rest-root/src/test/java/org/elasticsearch/rest/root/RestMainActionTests.java +++ b/modules/rest-root/src/test/java/org/elasticsearch/rest/root/RestMainActionTests.java @@ -37,14 +37,12 @@ public void testHeadResponse() throws Exception { final String clusterUUID = randomAlphaOfLengthBetween(10, 20); final Version version = Version.CURRENT; final IndexVersion indexVersion = IndexVersion.current(); - final TransportVersion transportVersion = TransportVersion.current(); final Build build = Build.current(); final MainResponse mainResponse = new MainResponse( nodeName, version, - indexVersion, - transportVersion, + indexVersion.luceneVersion().toString(), clusterName, clusterUUID, build @@ -78,8 +76,7 @@ public void testGetResponse() throws Exception { final MainResponse mainResponse = new MainResponse( nodeName, version, - indexVersion, - transportVersion, + indexVersion.luceneVersion().toString(), clusterName, clusterUUID, build diff --git a/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java b/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java index 8a632ec6d20f6..e10709a5b078a 100644 --- a/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java +++ b/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java @@ -8,6 +8,7 @@ package org.elasticsearch.qa.verify_version_constants; +import org.apache.lucene.tests.util.LuceneTestCase; import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; @@ -24,6 +25,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.lessThan; +@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/97736") public class VerifyVersionConstantsIT extends ESRestTestCase { public void testLuceneVersionConstant() throws IOException, ParseException { diff --git a/server/src/main/java/org/elasticsearch/TransportVersion.java b/server/src/main/java/org/elasticsearch/TransportVersion.java index de8a3b60cbf55..f95e05f689fd6 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersion.java +++ b/server/src/main/java/org/elasticsearch/TransportVersion.java @@ -156,12 +156,12 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId public static final TransportVersion V_8_500_033 = registerTransportVersion(8_500_033, "193ab7c4-a751-4cbd-a66a-2d7d56ccbc10"); public static final TransportVersion V_8_500_034 = registerTransportVersion(8_500_034, "16871c8b-88ba-4432-980a-10fd9ecad2dc"); public static final TransportVersion V_8_500_035 = registerTransportVersion(8_500_035, "664dd6ce-3487-4fbd-81a9-af778b28be45"); - // Introduced for stateless plugin public static final TransportVersion V_8_500_036 = registerTransportVersion(8_500_036, "3343c64f-d7ac-4f02-9262-3e1acfc56f89"); + public static final TransportVersion V_8_500_037 = registerTransportVersion(8_500_037, "d76a4f22-8878-43e0-acfa-15e452195fa7"); private static class CurrentHolder { - private static final TransportVersion CURRENT = findCurrent(V_8_500_036); + private static final TransportVersion CURRENT = findCurrent(V_8_500_037); // finds the pluggable current version, or uses the given fallback private static TransportVersion findCurrent(TransportVersion fallback) { diff --git a/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/WebServerTestCase.java b/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/WebServerTestCase.java index 7171be3f1b8bb..8591f4480d36e 100644 --- a/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/WebServerTestCase.java +++ b/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/WebServerTestCase.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.sql.jdbc; import org.elasticsearch.Build; -import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.index.IndexVersion; @@ -54,8 +53,7 @@ MainResponse createMainResponse(Version version) { final String date = new Date(randomNonNegativeLong()).toString(); Build build = new Build(Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString()); IndexVersion indexVersion = IndexVersion.current(); - TransportVersion transportVersion = TransportVersion.current(); - return new MainResponse(nodeName, version, indexVersion, transportVersion, clusterName, clusterUuid, build); + return new MainResponse(nodeName, version, indexVersion.luceneVersion().toString(), clusterName, clusterUuid, build); } String webServerAddress() {