From 0359c4f5e85bc5ed42b49ffed41067121711c888 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Mon, 2 Dec 2024 13:11:19 +0000 Subject: [PATCH 01/21] Address and remove all occurrences of the Java annotation @UpdateForV9 (ES-9378) --- .../test/rest/ClientYamlTestSuiteIT.java | 8 +-- .../org/elasticsearch/ReleaseVersions.java | 5 +- .../main/java/org/elasticsearch/Version.java | 20 ++++---- .../elasticsearch/cluster/ClusterState.java | 6 --- .../elasticsearch/index/IndexVersions.java | 2 - .../CompatibleNamedXContentRegistryTests.java | 3 -- .../index/IndexVersionTests.java | 1 - .../rest/yaml/ESClientYamlSuiteTestCase.java | 22 -------- .../test/rest/yaml/section/DoSection.java | 33 +++--------- .../yaml/section/PrerequisiteSection.java | 12 ----- .../rest/yaml/section/DoSectionTests.java | 51 ------------------- 11 files changed, 20 insertions(+), 143 deletions(-) diff --git a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java index 084e212a913b2..1334859719f3d 100644 --- a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java +++ b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java @@ -43,15 +43,9 @@ public ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate super(testCandidate); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // remove restCompat check @ParametersFactory public static Iterable parameters() throws Exception { - String restCompatProperty = System.getProperty("tests.restCompat"); - if ("true".equals(restCompatProperty)) { - return createParametersWithLegacyNodeSelectorSupport(); - } else { - return createParameters(); - } + return createParameters(); } @Override diff --git a/server/src/main/java/org/elasticsearch/ReleaseVersions.java b/server/src/main/java/org/elasticsearch/ReleaseVersions.java index 09d6bdd1b4799..22cd18c7b4ac3 100644 --- a/server/src/main/java/org/elasticsearch/ReleaseVersions.java +++ b/server/src/main/java/org/elasticsearch/ReleaseVersions.java @@ -10,7 +10,7 @@ package org.elasticsearch; import org.elasticsearch.common.Strings; -import org.elasticsearch.core.UpdateForV9; +import org.elasticsearch.core.UpdateForV10; import org.elasticsearch.internal.BuildExtension; import org.elasticsearch.plugins.ExtensionLoader; @@ -114,8 +114,7 @@ private static IntFunction lookupFunction(NavigableMap, ToXContentFragment { VERSION_STRINGS = Map.copyOf(builderByString); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - // Re-enable this assertion once the rest api version is bumped private static void assertRestApiVersion() { - // assert RestApiVersion.current().major == CURRENT.major && RestApiVersion.previous().major == CURRENT.major - 1 - // : "RestApiVersion must be upgraded " - // + "to reflect major from Version.CURRENT [" - // + CURRENT.major - // + "]" - // + " but is still set to [" - // + RestApiVersion.current().major - // + "]"; + assert RestApiVersion.current().major == CURRENT.major && RestApiVersion.previous().major == CURRENT.major - 1 + : "RestApiVersion must be upgraded " + + "to reflect major from Version.CURRENT [" + + CURRENT.major + + "]" + + " but is still set to [" + + RestApiVersion.current().major + + "]"; } public static Version readVersion(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java index 1364f0c78f3be..8b51f42c0d615 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -1037,12 +1037,6 @@ public static ClusterState readFrom(StreamInput in, DiscoveryNode localNode) thr return builder.build(); } - /** - * If the cluster state does not contain transport version information, this is the version - * that is inferred for all nodes on version 8.8.0 or above. - */ - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - public static final TransportVersion INFERRED_TRANSPORT_VERSION = TransportVersions.V_8_8_0; public static final Version VERSION_INTRODUCING_TRANSPORT_VERSIONS = Version.V_8_8_0; @Override diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 6344aa2a72ca9..7ea50729ffa7e 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -62,13 +62,11 @@ private static Version parseUnchecked(String version) { public static final IndexVersion ZERO = def(0, Version.LATEST); public static final IndexVersion V_7_0_0 = def(7_00_00_99, parseUnchecked("8.0.0")); - public static final IndexVersion V_7_1_0 = def(7_01_00_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_2_0 = def(7_02_00_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_2_1 = def(7_02_01_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_3_0 = def(7_03_00_99, parseUnchecked("8.1.0")); public static final IndexVersion V_7_4_0 = def(7_04_00_99, parseUnchecked("8.2.0")); public static final IndexVersion V_7_5_0 = def(7_05_00_99, parseUnchecked("8.3.0")); - public static final IndexVersion V_7_5_2 = def(7_05_02_99, parseUnchecked("8.3.0")); public static final IndexVersion V_7_6_0 = def(7_06_00_99, parseUnchecked("8.4.0")); public static final IndexVersion V_7_7_0 = def(7_07_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_8_0 = def(7_08_00_99, parseUnchecked("8.5.1")); diff --git a/server/src/test/java/org/elasticsearch/common/xcontent/CompatibleNamedXContentRegistryTests.java b/server/src/test/java/org/elasticsearch/common/xcontent/CompatibleNamedXContentRegistryTests.java index de1990361e766..8f62f8d33eacd 100644 --- a/server/src/test/java/org/elasticsearch/common/xcontent/CompatibleNamedXContentRegistryTests.java +++ b/server/src/test/java/org/elasticsearch/common/xcontent/CompatibleNamedXContentRegistryTests.java @@ -12,7 +12,6 @@ import org.elasticsearch.Version; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.core.RestApiVersion; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.rest.FakeRestRequest; @@ -116,8 +115,6 @@ public static NewSubObject parse(XContentParser parser) { } } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "this can be re-enabled once our rest api version is bumped to V_9") public void testNotCompatibleRequest() throws IOException { NamedXContentRegistry registry = new NamedXContentRegistry( List.of( diff --git a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java index 2a425c9256c31..d0dae702c1f56 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java @@ -194,7 +194,6 @@ public void testParseLenient() { } @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "can be unmuted once lucene is bumped to version 10") public void testLuceneVersionOnUnknownVersions() { // between two known versions, should use the lucene version of the previous version IndexVersion previousVersion = IndexVersionUtils.getPreviousVersion(); diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java index 54602090050ab..cea4a419b7465 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java @@ -217,28 +217,6 @@ public static void closeClient() throws IOException { } } - /** - * Create parameters for this parameterized test. - * Enables support for parsing the legacy version-based node_selector format. - */ - @Deprecated - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - public static Iterable createParametersWithLegacyNodeSelectorSupport() throws Exception { - var executableSectionRegistry = new NamedXContentRegistry( - Stream.concat( - ExecutableSection.DEFAULT_EXECUTABLE_CONTEXTS.stream().filter(entry -> entry.name.getPreferredName().equals("do") == false), - Stream.of( - new NamedXContentRegistry.Entry( - ExecutableSection.class, - new ParseField("do"), - DoSection::parseWithLegacyNodeSelectorSupport - ) - ) - ).toList() - ); - return createParameters(executableSectionRegistry, null); - } - /** * Create parameters for this parameterized test. Uses the * {@link ExecutableSection#XCONTENT_REGISTRY list} of executable sections diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 627554f6b261d..9565dbce86e17 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -19,7 +19,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.HeaderWarning; import org.elasticsearch.core.Tuple; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.index.mapper.SourceFieldMapper; import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction; import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext; @@ -84,16 +83,6 @@ */ public class DoSection implements ExecutableSection { public static DoSection parse(XContentParser parser) throws IOException { - return parse(parser, false); - } - - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @Deprecated - public static DoSection parseWithLegacyNodeSelectorSupport(XContentParser parser) throws IOException { - return parse(parser, true); - } - - private static DoSection parse(XContentParser parser, boolean enableLegacyNodeSelectorSupport) throws IOException { String currentFieldName = null; XContentParser.Token token; @@ -183,7 +172,7 @@ private static DoSection parse(XContentParser parser, boolean enableLegacyNodeSe if (token == XContentParser.Token.FIELD_NAME) { selectorName = parser.currentName(); } else { - NodeSelector newSelector = buildNodeSelector(selectorName, parser, enableLegacyNodeSelectorSupport); + NodeSelector newSelector = buildNodeSelector(selectorName, parser); nodeSelector = nodeSelector == NodeSelector.ANY ? newSelector : new ComposeNodeSelector(nodeSelector, newSelector); @@ -604,11 +593,11 @@ private String formatStatusCodeMessage(ClientYamlTestResponse restTestResponse, ) ); - private static NodeSelector buildNodeSelector(String name, XContentParser parser, boolean enableLegacyVersionSupport) + private static NodeSelector buildNodeSelector(String name, XContentParser parser) throws IOException { return switch (name) { case "attribute" -> parseAttributeValuesSelector(parser); - case "version" -> parseVersionSelector(parser, enableLegacyVersionSupport); + case "version" -> parseVersionSelector(parser); default -> throw new XContentParseException(parser.getTokenLocation(), "unknown node_selector [" + name + "]"); }; } @@ -673,7 +662,7 @@ private static boolean matchWithRange( } } - private static NodeSelector parseVersionSelector(XContentParser parser, boolean enableLegacyVersionSupport) throws IOException { + private static NodeSelector parseVersionSelector(XContentParser parser) throws IOException { if (false == parser.currentToken().isValue()) { throw new XContentParseException(parser.getTokenLocation(), "expected [version] to be a value"); } @@ -687,16 +676,10 @@ private static NodeSelector parseVersionSelector(XContentParser parser, boolean nodeMatcher = nodeVersion -> Build.current().version().equals(nodeVersion) == false; versionSelectorString = "version is not current (original)"; } else { - if (enableLegacyVersionSupport) { - var acceptedVersionRange = VersionRange.parseVersionRanges(parser.text()); - nodeMatcher = nodeVersion -> matchWithRange(nodeVersion, acceptedVersionRange, parser.getTokenLocation()); - versionSelectorString = "version ranges " + acceptedVersionRange; - } else { - throw new XContentParseException( - parser.getTokenLocation(), - "unknown version selector [" + parser.text() + "]. Only [current] and [original] are allowed." - ); - } + throw new XContentParseException( + parser.getTokenLocation(), + "unknown version selector [" + parser.text() + "]. Only [current] and [original] are allowed." + ); } return new NodeSelector() { diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java index bbbf73d74e4ca..23c9548d8157e 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java @@ -305,7 +305,6 @@ static void parseSkipSection(XContentParser parser, PrerequisiteSectionBuilder b boolean valid = false; if (parser.currentToken().isValue()) { valid = switch (parser.currentName()) { - case "version" -> parseRestCompatVersion(parser, builder); case "reason" -> parseString(parser, builder::setSkipReason); case "features" -> parseString(parser, f -> parseFeatureField(f, builder)); case "os" -> parseString(parser, builder::skipIfOs); @@ -328,17 +327,6 @@ static void parseSkipSection(XContentParser parser, PrerequisiteSectionBuilder b parser.nextToken(); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - private static boolean parseRestCompatVersion(XContentParser parser, PrerequisiteSectionBuilder builder) throws IOException { - // allow skip version only for v7 REST compatibility tests, to be removed for V9 - if ("true".equals(System.getProperty("tests.restCompat"))) return parseString(parser, builder::skipIfVersion); - throw new IllegalArgumentException( - "Skipping by version is no longer supported, please skip based on cluster features. Please check the docs: \n" - + "https://github.com/elastic/elasticsearch/tree/main" - + "/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test#skipping-tests" - ); - } - private static void throwUnexpectedField(String section, XContentParser parser) throws IOException { throw new ParsingException( parser.getTokenLocation(), diff --git a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java index ee8d75b4c034b..7a8b2ef19208c 100644 --- a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java +++ b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java @@ -580,57 +580,6 @@ public void testParseDoSectionAllowedWarnings() throws Exception { assertThat(e.getMessage(), equalTo("the warning [foo] was both allowed and expected")); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // remove - public void testLegacyNodeSelectorByVersionRange() throws IOException { - parser = createParser(YamlXContent.yamlXContent, """ - node_selector: - version: 5.2.0-6.0.0 - indices.get_field_mapping: - index: test_index"""); - - DoSection doSection = DoSection.parseWithLegacyNodeSelectorSupport(parser); - assertNotSame(NodeSelector.ANY, doSection.getApiCallSection().getNodeSelector()); - Node v170 = nodeWithVersion("1.7.0"); - Node v521 = nodeWithVersion("5.2.1"); - Node v550 = nodeWithVersion("5.5.0"); - Node v612 = nodeWithVersion("6.1.2"); - List nodes = new ArrayList<>(); - nodes.add(v170); - nodes.add(v521); - nodes.add(v550); - nodes.add(v612); - doSection.getApiCallSection().getNodeSelector().select(nodes); - assertEquals(Arrays.asList(v521, v550), nodes); - ClientYamlTestExecutionContext context = mock(ClientYamlTestExecutionContext.class); - ClientYamlTestResponse mockResponse = mock(ClientYamlTestResponse.class); - when( - context.callApi( - "indices.get_field_mapping", - singletonMap("index", "test_index"), - emptyList(), - emptyMap(), - doSection.getApiCallSection().getNodeSelector() - ) - ).thenReturn(mockResponse); - when(context.nodesVersions()).thenReturn(Set.of(randomAlphaOfLength(10))); - when(mockResponse.getHeaders("X-elastic-product")).thenReturn(List.of("Elasticsearch")); - doSection.execute(context); - verify(context).callApi( - "indices.get_field_mapping", - singletonMap("index", "test_index"), - emptyList(), - emptyMap(), - doSection.getApiCallSection().getNodeSelector() - ); - - { - List badNodes = new ArrayList<>(); - badNodes.add(new Node(new HttpHost("dummy"))); - Exception e = expectThrows(IllegalStateException.class, () -> doSection.getApiCallSection().getNodeSelector().select(badNodes)); - assertEquals("expected [version] metadata to be set but got [host=http://dummy]", e.getMessage()); - } - } - public void testNodeSelectorByVersionRangeFails() throws IOException { parser = createParser(YamlXContent.yamlXContent, """ node_selector: From 9355aa5f692aa5f3d726d6a22a4efa1a240bc693 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 14:11:07 +0000 Subject: [PATCH 02/21] More changes for V9 --- .../org/elasticsearch/env/NodeMetadata.java | 3 +-- .../indices/recovery/RecoverySettings.java | 1 - .../snapshots/SnapshotsService.java | 4 ---- .../elasticsearch/env/NodeMetadataTests.java | 20 ++++++++----------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java index c71a3798be1f7..2b64851d7d6bb 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java +++ b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java @@ -158,12 +158,11 @@ public void setOldestIndexVersion(int oldestIndexVersion) { this.oldestIndexVersion = IndexVersion.fromId(oldestIndexVersion); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // version is required in the node metadata from v9 onwards public NodeMetadata build() { final IndexVersion oldestIndexVersion; if (this.nodeVersion == null) { - nodeVersion = BuildVersion.fromVersionId(0); + throw new IllegalStateException("Node version is required in node metadata"); } if (this.previousNodeVersion == null) { previousNodeVersion = nodeVersion; diff --git a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java index 1ec187ea4a34b..007502b472626 100644 --- a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java +++ b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -49,7 +49,6 @@ import static org.elasticsearch.node.NodeRoleSettings.NODE_ROLES_SETTING; public class RecoverySettings { - public static final IndexVersion SNAPSHOT_RECOVERIES_SUPPORTED_INDEX_VERSION = IndexVersions.V_7_15_0; public static final TransportVersion SNAPSHOT_RECOVERIES_SUPPORTED_TRANSPORT_VERSION = TransportVersions.V_7_15_0; public static final IndexVersion SEQ_NO_SNAPSHOT_RECOVERIES_SUPPORTED_VERSION = IndexVersions.V_7_16_0; public static final TransportVersion SNAPSHOT_FILE_DOWNLOAD_THROTTLING_SUPPORTED_TRANSPORT_VERSION = TransportVersions.V_7_16_0; diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 8d526f3e114e1..9755648b49532 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -2360,10 +2360,6 @@ public static boolean includesUUIDs(IndexVersion repositoryMetaVersion) { return repositoryMetaVersion.onOrAfter(UUIDS_IN_REPO_DATA_VERSION); } - public static boolean includeFileInfoWriterUUID(IndexVersion repositoryMetaVersion) { - return repositoryMetaVersion.onOrAfter(FILE_INFO_WRITER_UUIDS_IN_SHARD_DATA_VERSION); - } - /** Deletes snapshot from repository * * @param deleteEntry delete entry in cluster state diff --git a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java index 22308e15f4845..2f084ef6549a7 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java @@ -9,12 +9,12 @@ package org.elasticsearch.env; import org.elasticsearch.Build; +import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.core.Tuple; import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.gateway.MetadataStateFormat; import org.elasticsearch.index.IndexVersion; -import org.elasticsearch.index.IndexVersions; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.EqualsHashCodeTestUtils; import org.elasticsearch.test.VersionUtils; @@ -80,22 +80,18 @@ public void testEqualsHashcodeSerialization() { ); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "as mentioned in the comment below, the behavior here is changing for 9.0 so this test needs updating") - public void testReadsFormatWithoutVersion() throws IOException { - // the behaviour tested here is only appropriate if the current version is compatible with versions 7 and earlier - assertTrue(IndexVersions.MINIMUM_COMPATIBLE.onOrBefore(IndexVersions.V_7_0_0)); - // when the current version is incompatible with version 7, the behaviour should change to reject files like the given resource - // which do not have the version field - + public void testFailsToReadFormatWithoutVersion() throws IOException { final Path tempDir = createTempDir(); final Path stateDir = Files.createDirectory(tempDir.resolve(MetadataStateFormat.STATE_DIR_NAME)); final InputStream resource = this.getClass().getResourceAsStream("testReadsFormatWithoutVersion.binary"); assertThat(resource, notNullValue()); Files.copy(resource, stateDir.resolve(NodeMetadata.FORMAT.getStateFileName(between(0, Integer.MAX_VALUE)))); - final NodeMetadata nodeMetadata = NodeMetadata.FORMAT.loadLatestState(logger, xContentRegistry(), tempDir); - assertThat(nodeMetadata.nodeId(), equalTo("y6VUVMSaStO4Tz-B5BxcOw")); - assertThat(nodeMetadata.nodeVersion(), equalTo(BuildVersion.fromVersionId(0))); + + ElasticsearchException ex = assertThrows(ElasticsearchException.class, + () -> NodeMetadata.FORMAT.loadLatestState(logger, xContentRegistry(), tempDir)); + Throwable rootCause = ex.getRootCause(); + assertTrue(rootCause instanceof IllegalStateException); + assertEquals("Node version is required in node metadata", rootCause.getMessage()); } public void testUpgradesLegitimateVersions() { From af4d6d68de1a4e7c5a6370a70c3740f33226e061 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 15:14:15 +0000 Subject: [PATCH 03/21] Remove unused versions --- .../main/java/org/elasticsearch/index/IndexVersions.java | 6 ------ .../java/org/elasticsearch/index/mapper/MapperTestCase.java | 2 -- 2 files changed, 8 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 7ea50729ffa7e..8acf648209b61 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -68,17 +68,11 @@ private static Version parseUnchecked(String version) { public static final IndexVersion V_7_4_0 = def(7_04_00_99, parseUnchecked("8.2.0")); public static final IndexVersion V_7_5_0 = def(7_05_00_99, parseUnchecked("8.3.0")); public static final IndexVersion V_7_6_0 = def(7_06_00_99, parseUnchecked("8.4.0")); - public static final IndexVersion V_7_7_0 = def(7_07_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_8_0 = def(7_08_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_9_0 = def(7_09_00_99, parseUnchecked("8.6.0")); public static final IndexVersion V_7_10_0 = def(7_10_00_99, parseUnchecked("8.7.0")); - public static final IndexVersion V_7_11_0 = def(7_11_00_99, parseUnchecked("8.7.0")); public static final IndexVersion V_7_12_0 = def(7_12_00_99, parseUnchecked("8.8.0")); - public static final IndexVersion V_7_13_0 = def(7_13_00_99, parseUnchecked("8.8.2")); - public static final IndexVersion V_7_14_0 = def(7_14_00_99, parseUnchecked("8.9.0")); - public static final IndexVersion V_7_15_0 = def(7_15_00_99, parseUnchecked("8.9.0")); public static final IndexVersion V_7_16_0 = def(7_16_00_99, parseUnchecked("8.10.1")); - public static final IndexVersion V_7_17_0 = def(7_17_00_99, parseUnchecked("8.11.1")); public static final IndexVersion V_8_0_0 = def(8_00_00_99, Version.LUCENE_9_0_0); public static final IndexVersion V_8_1_0 = def(8_01_00_99, Version.LUCENE_9_0_0); public static final IndexVersion V_8_2_0 = def(8_02_00_99, Version.LUCENE_9_1_0); diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java index 29bb3b15a9f86..14d87149bfd9b 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperTestCase.java @@ -94,8 +94,6 @@ */ public abstract class MapperTestCase extends MapperServiceTestCase { - public static final IndexVersion DEPRECATED_BOOST_INDEX_VERSION = IndexVersions.V_7_10_0; - protected abstract void minimalMapping(XContentBuilder b) throws IOException; /** From 7ebfa1edac7eefbb3669dd7acde42a9fd3c7fbf1 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 15:18:56 +0000 Subject: [PATCH 04/21] Fix compilation --- .../repositories/blobstore/BlobStoreRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index f1c3d82b74cab..c5a92a323836e 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -3326,7 +3326,7 @@ private void doSnapshotShard(SnapshotShardContext context) { final ShardGeneration indexGeneration; final boolean writeShardGens = SnapshotsService.useShardGenerations(context.getRepositoryMetaVersion()); - final boolean writeFileInfoWriterUUID = SnapshotsService.includeFileInfoWriterUUID(context.getRepositoryMetaVersion()); + final boolean writeFileInfoWriterUUID = true; // build a new BlobStoreIndexShardSnapshot, that includes this one and all the saved ones final BlobStoreIndexShardSnapshots updatedBlobStoreIndexShardSnapshots = snapshots.withAddedSnapshot( new SnapshotFiles(snapshotId.getName(), indexCommitPointFiles, context.stateIdentifier()) From dbfdffa46bad94d6f2e5da19307666184904d61e Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 15:38:08 +0000 Subject: [PATCH 05/21] Fix compilation --- .../recovery/plan/SnapshotsRecoveryPlannerService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java b/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java index f58c6599050de..7d39992f663f3 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java @@ -17,7 +17,6 @@ import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetadata; -import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.recovery.plan.RecoveryPlannerService; import org.elasticsearch.indices.recovery.plan.ShardRecoveryPlan; import org.elasticsearch.indices.recovery.plan.ShardSnapshot; @@ -60,9 +59,7 @@ public void computeRecoveryPlan( ActionListener listener ) { // Fallback to source only recovery if the target node is in an incompatible version - boolean canUseSnapshots = isLicenseActive.getAsBoolean() - && useSnapshots - && targetVersion.onOrAfter(RecoverySettings.SNAPSHOT_RECOVERIES_SUPPORTED_INDEX_VERSION); + boolean canUseSnapshots = isLicenseActive.getAsBoolean() && useSnapshots; fetchLatestSnapshotsIgnoringErrors( shardId, From 7e16865c1a89badfba5ddf059eb6c28f2e1f7efb Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 15:55:54 +0000 Subject: [PATCH 06/21] Remove unused import --- .../java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java index 1334859719f3d..675092bffe8d5 100644 --- a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java +++ b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java @@ -14,7 +14,6 @@ import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.tests.util.TimeUnits; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; From 75691c2cd168efa8cf8e9a9dd388078aa9535c0a Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 16:20:39 +0000 Subject: [PATCH 07/21] Checkstyle fixes --- .../src/main/java/org/elasticsearch/Version.java | 16 ++++++++-------- .../org/elasticsearch/cluster/ClusterState.java | 1 - .../java/org/elasticsearch/env/NodeMetadata.java | 1 - .../org/elasticsearch/env/NodeMetadataTests.java | 6 ++++-- .../rest/yaml/ESClientYamlSuiteTestCase.java | 4 ---- .../test/rest/yaml/section/DoSection.java | 3 +-- .../rest/yaml/section/PrerequisiteSection.java | 1 - .../test/rest/yaml/section/DoSectionTests.java | 8 -------- 8 files changed, 13 insertions(+), 27 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index d27402f25dd4f..9be91bb66f3ae 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -239,14 +239,14 @@ public class Version implements VersionId, ToXContentFragment { } private static void assertRestApiVersion() { - assert RestApiVersion.current().major == CURRENT.major && RestApiVersion.previous().major == CURRENT.major - 1 - : "RestApiVersion must be upgraded " - + "to reflect major from Version.CURRENT [" - + CURRENT.major - + "]" - + " but is still set to [" - + RestApiVersion.current().major - + "]"; + assert RestApiVersion.current().major == CURRENT.major && RestApiVersion.previous().major == CURRENT.major - 1 + : "RestApiVersion must be upgraded " + + "to reflect major from Version.CURRENT [" + + CURRENT.major + + "]" + + " but is still set to [" + + RestApiVersion.current().major + + "]"; } public static Version readVersion(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java index 8b51f42c0d615..6bd838a84c133 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -47,7 +47,6 @@ import org.elasticsearch.common.xcontent.ChunkedToXContentHelper; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.SuppressForbidden; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.index.shard.IndexLongFieldRange; import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.xcontent.ToXContent; diff --git a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java index 2b64851d7d6bb..48268b5001f3e 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java +++ b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java @@ -10,7 +10,6 @@ package org.elasticsearch.env; import org.elasticsearch.Build; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.gateway.MetadataStateFormat; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.IndexVersions; diff --git a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java index 2f084ef6549a7..1e7a90202b5be 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java @@ -87,8 +87,10 @@ public void testFailsToReadFormatWithoutVersion() throws IOException { assertThat(resource, notNullValue()); Files.copy(resource, stateDir.resolve(NodeMetadata.FORMAT.getStateFileName(between(0, Integer.MAX_VALUE)))); - ElasticsearchException ex = assertThrows(ElasticsearchException.class, - () -> NodeMetadata.FORMAT.loadLatestState(logger, xContentRegistry(), tempDir)); + ElasticsearchException ex = assertThrows( + ElasticsearchException.class, + () -> NodeMetadata.FORMAT.loadLatestState(logger, xContentRegistry(), tempDir) + ); Throwable rootCause = ex.getRootCause(); assertTrue(rootCause instanceof IllegalStateException); assertEquals("Node version is required in node metadata", rootCause.getMessage()); diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java index cea4a419b7465..15ebcf3d1feb7 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java @@ -25,7 +25,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.core.IOUtils; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.test.ClasspathUtils; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.TestFeatureService; @@ -33,10 +32,8 @@ import org.elasticsearch.test.rest.yaml.restspec.ClientYamlSuiteRestSpec; import org.elasticsearch.test.rest.yaml.section.ClientYamlTestSection; import org.elasticsearch.test.rest.yaml.section.ClientYamlTestSuite; -import org.elasticsearch.test.rest.yaml.section.DoSection; import org.elasticsearch.test.rest.yaml.section.ExecutableSection; import org.elasticsearch.xcontent.NamedXContentRegistry; -import org.elasticsearch.xcontent.ParseField; import org.junit.AfterClass; import org.junit.Before; @@ -58,7 +55,6 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Runs a suite of yaml tests shared with all the official Elasticsearch diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index 9565dbce86e17..5a212e5b1ec58 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -593,8 +593,7 @@ private String formatStatusCodeMessage(ClientYamlTestResponse restTestResponse, ) ); - private static NodeSelector buildNodeSelector(String name, XContentParser parser) - throws IOException { + private static NodeSelector buildNodeSelector(String name, XContentParser parser) throws IOException { return switch (name) { case "attribute" -> parseAttributeValuesSelector(parser); case "version" -> parseVersionSelector(parser); diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java index 23c9548d8157e..ef18a7852840b 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/section/PrerequisiteSection.java @@ -12,7 +12,6 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.core.CheckedFunction; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext; import org.elasticsearch.test.rest.yaml.Features; import org.elasticsearch.xcontent.XContentLocation; diff --git a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java index 7a8b2ef19208c..465ff7c73e74b 100644 --- a/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java +++ b/test/yaml-rest-runner/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java @@ -16,9 +16,6 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.logging.HeaderWarning; import org.elasticsearch.core.Strings; -import org.elasticsearch.core.UpdateForV9; -import org.elasticsearch.test.rest.yaml.ClientYamlTestExecutionContext; -import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.xcontent.XContentLocation; import org.elasticsearch.xcontent.XContentParseException; import org.elasticsearch.xcontent.XContentParser; @@ -31,11 +28,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.regex.Pattern; import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.hamcrest.CoreMatchers.equalTo; @@ -43,9 +38,6 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; public class DoSectionTests extends AbstractClientYamlTestFragmentParserTestCase { From 4f20defa5159bf7db2da6b5bd0112c7f0a00021a Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 4 Dec 2024 17:31:07 +0000 Subject: [PATCH 08/21] Remove annotation (ES-9734) --- .../xpack/deprecation/NodesDeprecationCheckAction.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java index 2e40481f7c561..48009f8105429 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckAction.java @@ -12,7 +12,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.xpack.core.deprecation.DeprecationIssue; @@ -32,7 +31,6 @@ private NodesDeprecationCheckAction() { super(NAME); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // this can be replaced with TransportRequest.Empty in v9 public static class NodeRequest extends TransportRequest { public NodeRequest() {} @@ -40,11 +38,6 @@ public NodeRequest() {} public NodeRequest(StreamInput in) throws IOException { super(in); } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - } } public static class NodeResponse extends BaseNodeResponse { From 58866bd98dcf7313c5802728705e95450e72bec5 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Mon, 9 Dec 2024 16:27:33 +0000 Subject: [PATCH 09/21] Remove unused ThreadPoolTypes --- .../main/java/org/elasticsearch/threadpool/ThreadPool.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index f55e3740aaa8f..82afc7ae04b6e 100644 --- a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -120,13 +120,7 @@ public static class Names { public static final String THREAD_POOL_METRIC_NAME_REJECTED = ".threads.rejected.total"; public enum ThreadPoolType { - @Deprecated(forRemoval = true) - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // no longer used, remove in v9 - DIRECT("direct"), FIXED("fixed"), - @Deprecated(forRemoval = true) - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // no longer used, remove in v9 - FIXED_AUTO_QUEUE_SIZE("fixed_auto_queue_size"), SCALING("scaling"); private final String type; From 691ceb79a1865cab283f66380ee2be0e3d0a53d3 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 11 Dec 2024 13:34:04 +0000 Subject: [PATCH 10/21] Revert changes about IndexVersions --- .../src/main/java/org/elasticsearch/index/IndexVersions.java | 1 + .../org/elasticsearch/indices/recovery/RecoverySettings.java | 1 + .../repositories/blobstore/BlobStoreRepository.java | 2 +- .../java/org/elasticsearch/snapshots/SnapshotsService.java | 4 ++++ .../main/java/org/elasticsearch/threadpool/ThreadPool.java | 1 - .../recovery/plan/SnapshotsRecoveryPlannerService.java | 5 ++++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 4cbfe3f8e94ec..057c026556853 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -72,6 +72,7 @@ private static Version parseUnchecked(String version) { public static final IndexVersion V_7_9_0 = def(7_09_00_99, parseUnchecked("8.6.0")); public static final IndexVersion V_7_10_0 = def(7_10_00_99, parseUnchecked("8.7.0")); public static final IndexVersion V_7_12_0 = def(7_12_00_99, parseUnchecked("8.8.0")); + public static final IndexVersion V_7_15_0 = def(7_15_00_99, parseUnchecked("8.9.0")); public static final IndexVersion V_7_16_0 = def(7_16_00_99, parseUnchecked("8.10.1")); public static final IndexVersion V_8_0_0 = def(8_00_00_99, Version.LUCENE_9_0_0); public static final IndexVersion V_8_1_0 = def(8_01_00_99, Version.LUCENE_9_0_0); diff --git a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java index c8c0d73f61765..475f83de9cae3 100644 --- a/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java +++ b/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -49,6 +49,7 @@ import static org.elasticsearch.node.NodeRoleSettings.NODE_ROLES_SETTING; public class RecoverySettings { + public static final IndexVersion SNAPSHOT_RECOVERIES_SUPPORTED_INDEX_VERSION = IndexVersions.V_7_15_0; public static final TransportVersion SNAPSHOT_RECOVERIES_SUPPORTED_TRANSPORT_VERSION = TransportVersions.V_7_15_0; public static final IndexVersion SEQ_NO_SNAPSHOT_RECOVERIES_SUPPORTED_VERSION = IndexVersions.V_7_16_0; public static final TransportVersion SNAPSHOT_FILE_DOWNLOAD_THROTTLING_SUPPORTED_TRANSPORT_VERSION = TransportVersions.V_7_16_0; diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index a15e60e11965d..11386eba10196 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -3331,7 +3331,7 @@ private void doSnapshotShard(SnapshotShardContext context) { final ShardGeneration indexGeneration; final boolean writeShardGens = SnapshotsService.useShardGenerations(context.getRepositoryMetaVersion()); - final boolean writeFileInfoWriterUUID = true; + final boolean writeFileInfoWriterUUID = SnapshotsService.includeFileInfoWriterUUID(context.getRepositoryMetaVersion()); // build a new BlobStoreIndexShardSnapshot, that includes this one and all the saved ones final BlobStoreIndexShardSnapshots updatedBlobStoreIndexShardSnapshots = snapshots.withAddedSnapshot( new SnapshotFiles(snapshotId.getName(), indexCommitPointFiles, context.stateIdentifier()) diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 9755648b49532..8d526f3e114e1 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -2360,6 +2360,10 @@ public static boolean includesUUIDs(IndexVersion repositoryMetaVersion) { return repositoryMetaVersion.onOrAfter(UUIDS_IN_REPO_DATA_VERSION); } + public static boolean includeFileInfoWriterUUID(IndexVersion repositoryMetaVersion) { + return repositoryMetaVersion.onOrAfter(FILE_INFO_WRITER_UUIDS_IN_SHARD_DATA_VERSION); + } + /** Deletes snapshot from repository * * @param deleteEntry delete entry in cluster state diff --git a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index 82afc7ae04b6e..37a3ec586d104 100644 --- a/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -27,7 +27,6 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.node.Node; import org.elasticsearch.node.ReportingService; import org.elasticsearch.telemetry.metric.Instrument; diff --git a/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java b/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java index 7d39992f663f3..f58c6599050de 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/main/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/plan/SnapshotsRecoveryPlannerService.java @@ -17,6 +17,7 @@ import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetadata; +import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.recovery.plan.RecoveryPlannerService; import org.elasticsearch.indices.recovery.plan.ShardRecoveryPlan; import org.elasticsearch.indices.recovery.plan.ShardSnapshot; @@ -59,7 +60,9 @@ public void computeRecoveryPlan( ActionListener listener ) { // Fallback to source only recovery if the target node is in an incompatible version - boolean canUseSnapshots = isLicenseActive.getAsBoolean() && useSnapshots; + boolean canUseSnapshots = isLicenseActive.getAsBoolean() + && useSnapshots + && targetVersion.onOrAfter(RecoverySettings.SNAPSHOT_RECOVERIES_SUPPORTED_INDEX_VERSION); fetchLatestSnapshotsIgnoringErrors( shardId, From 1562b27eae666affccd93afcb14524736ea73d4d Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 11 Dec 2024 17:29:57 +0000 Subject: [PATCH 11/21] More updates for V9 --- .../cluster/metadata/IndexMetadata.java | 24 ------------------- .../common/settings/IndexScopedSettings.java | 11 +-------- .../common/settings/Setting.java | 15 ++++++------ .../elasticsearch/index/IndexSettings.java | 14 ----------- .../elasticsearch/index/IndexVersions.java | 2 -- .../elasticsearch/index/IndexingSlowLog.java | 14 ----------- .../elasticsearch/index/SearchSlowLog.java | 14 ----------- .../index/engine/EngineConfig.java | 13 ---------- .../org/elasticsearch/index/store/Store.java | 13 ---------- .../common/settings/SettingTests.java | 4 ++-- .../elasticsearch/env/NodeMetadataTests.java | 5 +--- .../index/IndexVersionTests.java | 5 ++-- 12 files changed, 13 insertions(+), 121 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 952789e1bf746..6baba8148cbac 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -510,30 +510,6 @@ public Iterator> settings() { Property.ServerlessPublic ); - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting INDEX_ROLLUP_SOURCE_UUID = Setting.simpleString( - "index.rollup.source.uuid", - Property.IndexScope, - Property.PrivateIndex, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting INDEX_ROLLUP_SOURCE_NAME = Setting.simpleString( - "index.rollup.source.name", - Property.IndexScope, - Property.PrivateIndex, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - public static final String KEY_IN_SYNC_ALLOCATIONS = "in_sync_allocations"; public static final List PARTIALLY_MOUNTED_INDEX_TIER_PREFERENCE = List.of(DataTier.DATA_FROZEN); diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java index fc8f128e92f32..b5427dd7e7bb5 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java @@ -208,16 +208,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings { IndexSettings.MODE, IndexMetadata.INDEX_ROUTING_PATH, IndexSettings.TIME_SERIES_START_TIME, - IndexSettings.TIME_SERIES_END_TIME, - - // Legacy index settings we must keep around for BWC from 7.x - EngineConfig.INDEX_OPTIMIZE_AUTO_GENERATED_IDS, - IndexMetadata.INDEX_ROLLUP_SOURCE_NAME, - IndexMetadata.INDEX_ROLLUP_SOURCE_UUID, - IndexSettings.MAX_ADJACENCY_MATRIX_FILTERS_SETTING, - IndexingSlowLog.INDEX_INDEXING_SLOWLOG_LEVEL_SETTING, - SearchSlowLog.INDEX_SEARCH_SLOWLOG_LEVEL, - Store.FORCE_RAM_TERM_DICT + IndexSettings.TIME_SERIES_END_TIME ); public static final IndexScopedSettings DEFAULT_SCOPED_SETTINGS = new IndexScopedSettings(Settings.EMPTY, BUILT_IN_INDEX_SETTINGS); diff --git a/server/src/main/java/org/elasticsearch/common/settings/Setting.java b/server/src/main/java/org/elasticsearch/common/settings/Setting.java index aec9c108d898d..b56bb0d09a260 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Setting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Setting.java @@ -148,11 +148,10 @@ public enum Property { PrivateIndex, /** - * Indicates that this index-level setting was deprecated in {@link Version#V_7_17_0} and is - * forbidden in indices created from {@link Version#V_8_0_0} onwards. + * Indicates that this index-level setting was deprecated in {@link Version#V_8_18_0} and is + * forbidden in indices created from {@link Version#V_9_0_0} onwards. */ - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // introduce IndexSettingDeprecatedInV8AndRemovedInV9 to replace this constant - IndexSettingDeprecatedInV7AndRemovedInV8, + IndexSettingDeprecatedInV8AndRemovedInV9, /** * Indicates that this setting is accessible by non-operator users (public) in serverless @@ -175,7 +174,7 @@ public enum Property { private static final EnumSet DEPRECATED_PROPERTIES = EnumSet.of( Property.Deprecated, Property.DeprecatedWarning, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 + Property.IndexSettingDeprecatedInV8AndRemovedInV9 ); @SuppressWarnings("this-escape") @@ -214,7 +213,7 @@ private Setting( checkPropertyRequiresIndexScope(propertiesAsSet, Property.NotCopyableOnResize); checkPropertyRequiresIndexScope(propertiesAsSet, Property.InternalIndex); checkPropertyRequiresIndexScope(propertiesAsSet, Property.PrivateIndex); - checkPropertyRequiresIndexScope(propertiesAsSet, Property.IndexSettingDeprecatedInV7AndRemovedInV8); + checkPropertyRequiresIndexScope(propertiesAsSet, Property.IndexSettingDeprecatedInV8AndRemovedInV9); checkPropertyRequiresNodeScope(propertiesAsSet); this.properties = propertiesAsSet; } @@ -449,7 +448,7 @@ public boolean hasIndexScope() { private boolean isDeprecated() { return properties.contains(Property.Deprecated) || properties.contains(Property.DeprecatedWarning) - || properties.contains(Property.IndexSettingDeprecatedInV7AndRemovedInV8); + || properties.contains(Property.IndexSettingDeprecatedInV8AndRemovedInV9); } private boolean isDeprecatedWarningOnly() { @@ -457,7 +456,7 @@ private boolean isDeprecatedWarningOnly() { } public boolean isDeprecatedAndRemoved() { - return properties.contains(Property.IndexSettingDeprecatedInV7AndRemovedInV8); + return properties.contains(Property.IndexSettingDeprecatedInV8AndRemovedInV9); } /** diff --git a/server/src/main/java/org/elasticsearch/index/IndexSettings.java b/server/src/main/java/org/elasticsearch/index/IndexSettings.java index 8f0373d951319..eafaf211b8870 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexSettings.java +++ b/server/src/main/java/org/elasticsearch/index/IndexSettings.java @@ -744,20 +744,6 @@ public Iterator> settings() { Property.ServerlessPublic ); - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting MAX_ADJACENCY_MATRIX_FILTERS_SETTING = Setting.intSetting( - "index.max_adjacency_matrix_filters", - 100, - 2, - Property.Dynamic, - Property.IndexScope, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - /** * The `index.mapping.ignore_above` setting defines the maximum length for the content of a field that will be indexed * or stored. If the length of the field’s content exceeds this limit, the field value will be ignored during indexing. diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 057c026556853..420cc0581c2ce 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -234,8 +234,6 @@ static NavigableMap getAllVersionIds(Class cls) { return Collections.unmodifiableNavigableMap(builder); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - // We can simplify this once we've removed all references to index versions earlier than MINIMUM_COMPATIBLE static Collection getAllVersions() { return VERSION_IDS.values().stream().filter(v -> v.onOrAfter(MINIMUM_COMPATIBLE)).toList(); } diff --git a/server/src/main/java/org/elasticsearch/index/IndexingSlowLog.java b/server/src/main/java/org/elasticsearch/index/IndexingSlowLog.java index 3ae4c0eb82ad0..9e39795814d38 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexingSlowLog.java +++ b/server/src/main/java/org/elasticsearch/index/IndexingSlowLog.java @@ -75,20 +75,6 @@ public final class IndexingSlowLog implements IndexingOperationListener { Property.IndexScope ); - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting INDEX_INDEXING_SLOWLOG_LEVEL_SETTING = new Setting<>( - INDEX_INDEXING_SLOWLOG_PREFIX + ".level", - SlowLogLevel.TRACE.name(), - SlowLogLevel::parse, - Property.Dynamic, - Property.IndexScope, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - private static final Logger indexLogger = LogManager.getLogger(INDEX_INDEXING_SLOWLOG_PREFIX + ".index"); private final Index index; diff --git a/server/src/main/java/org/elasticsearch/index/SearchSlowLog.java b/server/src/main/java/org/elasticsearch/index/SearchSlowLog.java index e4836a391bfec..983a3a960aaa5 100644 --- a/server/src/main/java/org/elasticsearch/index/SearchSlowLog.java +++ b/server/src/main/java/org/elasticsearch/index/SearchSlowLog.java @@ -110,20 +110,6 @@ public final class SearchSlowLog implements SearchOperationListener { Property.IndexScope ); - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting INDEX_SEARCH_SLOWLOG_LEVEL = new Setting<>( - INDEX_SEARCH_SLOWLOG_PREFIX + ".level", - SlowLogLevel.TRACE.name(), - SlowLogLevel::parse, - Property.Dynamic, - Property.IndexScope, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - private static final ToXContent.Params FORMAT_PARAMS = new ToXContent.MapParams(Collections.singletonMap("pretty", "false")); public SearchSlowLog(IndexSettings indexSettings, SlowLogFieldProvider slowLogFieldProvider) { diff --git a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java index af3c2cd5172f6..559b4d86d36cb 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/elasticsearch/index/engine/EngineConfig.java @@ -122,19 +122,6 @@ public Supplier retentionLeasesSupplier() { // don't convert to Setting<> and register... we only set this in tests and register via a test plugin public static final String USE_COMPOUND_FILE = "index.use_compound_file"; - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting INDEX_OPTIMIZE_AUTO_GENERATED_IDS = Setting.boolSetting( - "index.optimize_auto_generated_id", - true, - Property.IndexScope, - Property.Dynamic, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - private final TranslogConfig translogConfig; private final LongSupplier relativeTimeInNanosSupplier; diff --git a/server/src/main/java/org/elasticsearch/index/store/Store.java b/server/src/main/java/org/elasticsearch/index/store/Store.java index e6b499c07f189..02619834b321e 100644 --- a/server/src/main/java/org/elasticsearch/index/store/Store.java +++ b/server/src/main/java/org/elasticsearch/index/store/Store.java @@ -121,19 +121,6 @@ * */ public class Store extends AbstractIndexShardComponent implements Closeable, RefCounted { - - /** - * Legacy index setting, kept for 7.x BWC compatibility. This setting has no effect in 8.x. Do not use. - * TODO: Remove in 9.0 - */ - @Deprecated - public static final Setting FORCE_RAM_TERM_DICT = Setting.boolSetting( - "index.force_memory_term_dictionary", - false, - Property.IndexScope, - Property.IndexSettingDeprecatedInV7AndRemovedInV8 - ); - static final String CODEC = "store"; static final int CORRUPTED_MARKER_CODEC_VERSION = 2; // public is for test purposes diff --git a/server/src/test/java/org/elasticsearch/common/settings/SettingTests.java b/server/src/test/java/org/elasticsearch/common/settings/SettingTests.java index 75f5045c5fbb6..a846cd03dbccb 100644 --- a/server/src/test/java/org/elasticsearch/common/settings/SettingTests.java +++ b/server/src/test/java/org/elasticsearch/common/settings/SettingTests.java @@ -1515,11 +1515,11 @@ public void testDeprecationPropertyValidation() { ); expectThrows( IllegalArgumentException.class, - () -> Setting.boolSetting("a.bool.setting", true, Property.Deprecated, Property.IndexSettingDeprecatedInV7AndRemovedInV8) + () -> Setting.boolSetting("a.bool.setting", true, Property.Deprecated, Property.IndexSettingDeprecatedInV8AndRemovedInV9) ); expectThrows( IllegalArgumentException.class, - () -> Setting.boolSetting("a.bool.setting", true, Property.DeprecatedWarning, Property.IndexSettingDeprecatedInV7AndRemovedInV8) + () -> Setting.boolSetting("a.bool.setting", true, Property.DeprecatedWarning, Property.IndexSettingDeprecatedInV8AndRemovedInV9) ); } diff --git a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java index 1e7a90202b5be..ada1afe9b3e6e 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java @@ -12,7 +12,6 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.core.Tuple; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.gateway.MetadataStateFormat; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; @@ -153,11 +152,9 @@ public void testDoesNotUpgradeAncientVersion() { ); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "Needs to be updated for 9.0 version bump") public void testUpgradeMarksPreviousVersion() { final String nodeId = randomAlphaOfLength(10); - final Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.V_8_0_0); + final Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.V_9_0_0); final BuildVersion buildVersion = BuildVersion.fromVersionId(version.id()); final NodeMetadata nodeMetadata = new NodeMetadata(nodeId, buildVersion, IndexVersion.current()).upgradeToCurrentVersion(); diff --git a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java index d0dae702c1f56..eef9c34a30991 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java @@ -151,8 +151,6 @@ public void testMax() { } } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "believe this fails because index version has not yet been bumped to 9.0") public void testMinimumCompatibleVersion() { assertThat(IndexVersion.getMinimumCompatibleIndexVersion(7170099), equalTo(IndexVersion.fromId(6000099))); assertThat(IndexVersion.getMinimumCompatibleIndexVersion(8000099), equalTo(IndexVersion.fromId(7000099))); @@ -193,7 +191,8 @@ public void testParseLenient() { } } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) + @UpdateForV9(owner = UpdateForV9.Owner.SEARCH_FOUNDATIONS) + @AwaitsFix(bugUrl = "can be unmuted once lucene is bumped to version 10") public void testLuceneVersionOnUnknownVersions() { // between two known versions, should use the lucene version of the previous version IndexVersion previousVersion = IndexVersionUtils.getPreviousVersion(); From cc9268c2a50f32e9405ebb1d5667f52812852311 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Wed, 11 Dec 2024 20:02:22 +0000 Subject: [PATCH 12/21] Update TransportGetFeatureUpgradeStatusActionTests --- .../TransportGetFeatureUpgradeStatusActionTests.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java index 8a51963097dae..2b119c3c3f59c 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java @@ -13,8 +13,8 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.index.IndexVersion; +import org.elasticsearch.index.IndexVersions; import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.indices.SystemIndexDescriptorUtils; import org.elasticsearch.indices.SystemIndices; @@ -31,7 +31,8 @@ public class TransportGetFeatureUpgradeStatusActionTests extends ESTestCase { public static String TEST_SYSTEM_INDEX_PATTERN = ".test*"; - private static final IndexVersion TEST_OLD_VERSION = IndexVersion.fromId(6000099); + // Version just before MINIMUM_COMPATIBLE in order to check that UpgradeStatus.MIGRATION_NEEDED is set correctly + private static final IndexVersion TEST_OLD_VERSION = IndexVersion.fromId(IndexVersions.MINIMUM_COMPATIBLE.id() - 100); private static final ClusterState CLUSTER_STATE = getClusterState(); private static final SystemIndices.Feature FEATURE = getFeature(); @@ -85,8 +86,6 @@ private static ClusterState getClusterState() { .numberOfReplicas(0) .build(); - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - // Once we start testing 9.x, we should update this test to use a 7.x "version created" IndexMetadata indexMetadata2 = IndexMetadata.builder(".test-index-2") .settings(Settings.builder().put("index.version.created", TEST_OLD_VERSION).build()) .numberOfShards(1) From d7420d4d9e0b353d47ba022759c3324ca3619c25 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Thu, 12 Dec 2024 14:11:01 +0000 Subject: [PATCH 13/21] Update NodeEnvironment.getBestDowngradeVersion --- .../elasticsearch/env/NodeEnvironment.java | 28 ++++++------------- .../env/NodeEnvironmentTests.java | 25 ++++++++--------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java index f3a3fc9f771d4..1774bcb9e3513 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -23,6 +23,7 @@ import org.apache.lucene.store.NativeFSLockFactory; import org.elasticsearch.Build; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeRole; @@ -526,7 +527,7 @@ static void checkForIndexCompatibility(Logger logger, DataPath... dataPaths) thr if (metadata.oldestIndexVersion().isLegacyIndexVersion()) { - String bestDowngradeVersion = getBestDowngradeVersion(metadata.previousNodeVersion().toString()); + BuildVersion bestDowngradeVersion = getBestDowngradeVersion(metadata.previousNodeVersion()); throw new IllegalStateException( "Cannot start this node because it holds metadata for indices with version [" + metadata.oldestIndexVersion().toReleaseVersion() @@ -1505,28 +1506,17 @@ private static void tryWriteTempFile(Path path) throws IOException { /** * Get a useful version string to direct a user's downgrade operation * - *

If a user is trying to install 8.0 but has incompatible indices, the user should - * downgrade to 7.17.x. We return 7.17.0, unless the user is trying to upgrade from - * a 7.17.x release, in which case we return the last installed version. + *

If a user is trying to install 9.0 (current major) but has incompatible indices, the user should + * downgrade to 8.18.x (last minor of the previous major). We return 8.18.0, unless the user is trying to upgrade from + * a 8.18.x release, in which case we return the last installed version. * @return Version to downgrade to */ // visible for testing - static String getBestDowngradeVersion(String previousNodeVersion) { - // this method should only be called in the context of an upgrade to 8.x - assert Build.current().version().startsWith("9.") == false; - Pattern pattern = Pattern.compile("^7\\.(\\d+)\\.\\d+$"); - Matcher matcher = pattern.matcher(previousNodeVersion); - if (matcher.matches()) { - try { - int minorVersion = Integer.parseInt(matcher.group(1)); - if (minorVersion >= 17) { - return previousNodeVersion; - } - } catch (NumberFormatException e) { - // continue and return default - } + static BuildVersion getBestDowngradeVersion(BuildVersion previousNodeVersion) { + if (previousNodeVersion.onOrAfterMinimumCompatible()) { + return previousNodeVersion; } - return "7.17.0"; + return BuildVersion.fromVersionId(Version.CURRENT.minimumCompatibilityVersion().id); } } diff --git a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java index 42a94ebf8c6ff..b266999634fd0 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java @@ -638,20 +638,19 @@ public void testSymlinkDataDirectory() throws Exception { env.close(); } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "test won't work until we remove and bump minimum index versions") public void testGetBestDowngradeVersion() { - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.0"), Matchers.equalTo("7.17.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.5"), Matchers.equalTo("7.17.5")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.1234"), Matchers.equalTo("7.17.1234")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.18.0"), Matchers.equalTo("7.18.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.x"), Matchers.equalTo("7.17.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.5-SNAPSHOT"), Matchers.equalTo("7.17.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.17.6b"), Matchers.equalTo("7.17.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("7.16.0"), Matchers.equalTo("7.17.0")); - // when we get to version 7.2147483648.0 we will have to rethink our approach, but for now we return 7.17.0 with an integer overflow - assertThat(NodeEnvironment.getBestDowngradeVersion("7." + Integer.MAX_VALUE + "0.0"), Matchers.equalTo("7.17.0")); - assertThat(NodeEnvironment.getBestDowngradeVersion("foo"), Matchers.equalTo("7.17.0")); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0"))); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.5")), + Matchers.equalTo(BuildVersion.fromString("8.18.5"))); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.12")), + Matchers.equalTo(BuildVersion.fromString("8.18.12"))); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.19.0")), + Matchers.equalTo(BuildVersion.fromString("8.19.0"))); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.17.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0"))); + assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("7.17.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0"))); } private void verifyFailsOnShardData(Settings settings, Path indexPath, String shardDataDirName) { From 2708b040aa1d59b26dd951b41a96228c2bb706eb Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Thu, 12 Dec 2024 14:24:27 +0000 Subject: [PATCH 14/21] Update NodeEnvironmentTests.testIndexCompatibilityChecks --- .../java/org/elasticsearch/env/NodeEnvironmentTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java index b266999634fd0..8c29bfdfdb221 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.PathUtils; import org.elasticsearch.core.SuppressForbidden; +import org.elasticsearch.core.UpdateForV10; import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.gateway.MetadataStateFormat; import org.elasticsearch.gateway.PersistedClusterStateService; @@ -539,8 +540,6 @@ public void testBlocksDowngradeToVersionWithMultipleNodesInDataPath() throws IOE } } - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) - @AwaitsFix(bugUrl = "test won't work until we remove and bump minimum index versions") public void testIndexCompatibilityChecks() throws IOException { final Settings settings = buildEnvSettings(Settings.EMPTY); @@ -584,7 +583,8 @@ public void testIndexCompatibilityChecks() throws IOException { containsString("it holds metadata for indices with version [" + oldIndexVersion.toReleaseVersion() + "]"), containsString( "Revert this node to version [" - + (previousNodeVersion.major == Version.V_8_0_0.major ? Version.V_7_17_0 : previousNodeVersion) + + (previousNodeVersion.major == Version.CURRENT.major + ? Version.CURRENT.minimumCompatibilityVersion() : previousNodeVersion) + "]" ) ) From f458502a65cada648a39a173b53081e2e9350bb6 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Thu, 12 Dec 2024 14:41:09 +0000 Subject: [PATCH 15/21] Spotless --- .../elasticsearch/env/NodeEnvironment.java | 2 - .../env/NodeEnvironmentTests.java | 41 ++++++++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java index 1774bcb9e3513..1bbba074b5d87 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/elasticsearch/env/NodeEnvironment.java @@ -87,8 +87,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java index 8c29bfdfdb221..01250db18d945 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeEnvironmentTests.java @@ -30,8 +30,6 @@ import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.PathUtils; import org.elasticsearch.core.SuppressForbidden; -import org.elasticsearch.core.UpdateForV10; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.gateway.MetadataStateFormat; import org.elasticsearch.gateway.PersistedClusterStateService; import org.elasticsearch.index.Index; @@ -584,7 +582,8 @@ public void testIndexCompatibilityChecks() throws IOException { containsString( "Revert this node to version [" + (previousNodeVersion.major == Version.CURRENT.major - ? Version.CURRENT.minimumCompatibilityVersion() : previousNodeVersion) + ? Version.CURRENT.minimumCompatibilityVersion() + : previousNodeVersion) + "]" ) ) @@ -639,18 +638,30 @@ public void testSymlinkDataDirectory() throws Exception { } public void testGetBestDowngradeVersion() { - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.0")), - Matchers.equalTo(BuildVersion.fromString("8.18.0"))); - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.5")), - Matchers.equalTo(BuildVersion.fromString("8.18.5"))); - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.12")), - Matchers.equalTo(BuildVersion.fromString("8.18.12"))); - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.19.0")), - Matchers.equalTo(BuildVersion.fromString("8.19.0"))); - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.17.0")), - Matchers.equalTo(BuildVersion.fromString("8.18.0"))); - assertThat(NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("7.17.0")), - Matchers.equalTo(BuildVersion.fromString("8.18.0"))); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0")) + ); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.5")), + Matchers.equalTo(BuildVersion.fromString("8.18.5")) + ); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.18.12")), + Matchers.equalTo(BuildVersion.fromString("8.18.12")) + ); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.19.0")), + Matchers.equalTo(BuildVersion.fromString("8.19.0")) + ); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("8.17.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0")) + ); + assertThat( + NodeEnvironment.getBestDowngradeVersion(BuildVersion.fromString("7.17.0")), + Matchers.equalTo(BuildVersion.fromString("8.18.0")) + ); } private void verifyFailsOnShardData(Settings settings, Path indexPath, String shardDataDirName) { From a7b77d164a1d58c2bfa7085c72db44cbf0af10b8 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Thu, 12 Dec 2024 15:28:51 +0000 Subject: [PATCH 16/21] Restore check in RestCompatibleVersionHelper --- .../rest/RestCompatibleVersionHelper.java | 7 ++----- .../rest/RestCompatibleVersionHelperTests.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/RestCompatibleVersionHelper.java b/server/src/main/java/org/elasticsearch/rest/RestCompatibleVersionHelper.java index 07cc73f4da2b1..31758be719a66 100644 --- a/server/src/main/java/org/elasticsearch/rest/RestCompatibleVersionHelper.java +++ b/server/src/main/java/org/elasticsearch/rest/RestCompatibleVersionHelper.java @@ -11,7 +11,6 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.RestApiVersion; -import org.elasticsearch.core.UpdateForV9; import org.elasticsearch.xcontent.MediaType; import org.elasticsearch.xcontent.ParsedMediaType; @@ -27,7 +26,6 @@ class RestCompatibleVersionHelper { /** * @return The requested API version, or {@link Optional#empty()} if there was no explicit version in the request. */ - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) static Optional getCompatibleVersion( @Nullable ParsedMediaType acceptHeader, @Nullable ParsedMediaType contentTypeHeader, @@ -52,8 +50,7 @@ static Optional getCompatibleVersion( if (hasContent) { // content-type version must be current or prior - // This can be uncommented once all references to RestApiVersion.V_7 are removed - /*if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) { + if (contentTypeVersion > RestApiVersion.current().major || contentTypeVersion < RestApiVersion.minimumSupported().major) { throw new ElasticsearchStatusException( "Content-Type version must be either version {} or {}, but found {}. Content-Type={}", RestStatus.BAD_REQUEST, @@ -62,7 +59,7 @@ static Optional getCompatibleVersion( contentTypeVersion, contentTypeHeader ); - }*/ + } // if both accept and content-type are sent, the version must match if (contentTypeVersion != acceptVersion) { throw new ElasticsearchStatusException( diff --git a/server/src/test/java/org/elasticsearch/rest/RestCompatibleVersionHelperTests.java b/server/src/test/java/org/elasticsearch/rest/RestCompatibleVersionHelperTests.java index 040ab9fd5c2e9..96c7b409fd59a 100644 --- a/server/src/test/java/org/elasticsearch/rest/RestCompatibleVersionHelperTests.java +++ b/server/src/test/java/org/elasticsearch/rest/RestCompatibleVersionHelperTests.java @@ -210,11 +210,14 @@ public void testObsoleteVersion() { assertThat( e.getMessage(), equalTo( - "A compatible version is required on both Content-Type and Accept headers if either one has requested a " - + "compatible version and the compatible versions must match. " - + "Accept=" - + acceptHeader(PREVIOUS_VERSION) - + ", Content-Type=" + "Content-Type version must be either version " + + CURRENT_VERSION + + " or " + + PREVIOUS_VERSION + + ", but found " + + OBSOLETE_VERSION + + ". " + + "Content-Type=" + contentTypeHeader(OBSOLETE_VERSION) ) ); From 2b63f8cb7809ea706e281f2882dfc1e243811c4a Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Thu, 12 Dec 2024 20:46:15 +0000 Subject: [PATCH 17/21] Remove unused system property --- .../compat/AbstractYamlRestCompatTestPlugin.java | 1 - .../test/junit/listeners/ReproduceInfoPrinter.java | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java index ca669276123b3..cc5a139d50be9 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java @@ -243,7 +243,6 @@ public void apply(Project project) { // setup the test task TaskProvider yamlRestCompatTestTask = registerTestTask(project, yamlCompatTestSourceSet); yamlRestCompatTestTask.configure(testTask -> { - testTask.systemProperty("tests.restCompat", true); // Use test runner and classpath from "normal" yaml source set FileCollection outputFileCollection = yamlCompatTestSourceSet.getOutput(); testTask.setTestClassesDirs( diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index b627a8803bf21..d73f446710458 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -92,21 +92,9 @@ public void testFailure(Failure failure) throws Exception { GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b); gradleMessageBuilder.appendAllOpts(failure.getDescription()); - if (isRestApiCompatibilityTest()) { - b.append(System.lineSeparator()); - b.append( - "This is a Rest Api Compatibility Test. " - + "See the developers guide for details how to troubleshoot - " - + "https://github.com/elastic/elasticsearch/blob/master/REST_API_COMPATIBILITY.md" - ); - } printToErr(b.toString()); } - private static boolean isRestApiCompatibilityTest() { - return Boolean.parseBoolean(System.getProperty("tests.restCompat", "false")); - } - @SuppressForbidden(reason = "printing repro info") private static void printToErr(String s) { System.err.println(s); From cdc716a6f5313ed100d5b8c10e6e5193955295d5 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Fri, 13 Dec 2024 14:08:40 +0000 Subject: [PATCH 18/21] Address review comments --- .../src/main/java/org/elasticsearch/index/IndexVersions.java | 2 ++ .../test/java/org/elasticsearch/env/NodeMetadataTests.java | 5 +++-- .../test/java/org/elasticsearch/index/IndexVersionTests.java | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 9fb0b271d7d55..cb4f677fda423 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -236,6 +236,8 @@ static NavigableMap getAllVersionIds(Class cls) { return Collections.unmodifiableNavigableMap(builder); } + @UpdateForV9(owner = UpdateForV9.Owner.SEARCH_FOUNDATIONS) + // We can simplify this once we've removed all references to index versions earlier than MINIMUM_COMPATIBLE static Collection getAllVersions() { return VERSION_IDS.values().stream().filter(v -> v.onOrAfter(MINIMUM_COMPATIBLE)).toList(); } diff --git a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java index ada1afe9b3e6e..e20fe8946fbb6 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeMetadataTests.java @@ -27,6 +27,7 @@ import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; @@ -91,8 +92,8 @@ public void testFailsToReadFormatWithoutVersion() throws IOException { () -> NodeMetadata.FORMAT.loadLatestState(logger, xContentRegistry(), tempDir) ); Throwable rootCause = ex.getRootCause(); - assertTrue(rootCause instanceof IllegalStateException); - assertEquals("Node version is required in node metadata", rootCause.getMessage()); + assertThat(rootCause, instanceOf(IllegalStateException.class)); + assertThat("Node version is required in node metadata", equalTo(rootCause.getMessage())); } public void testUpgradesLegitimateVersions() { diff --git a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java index eef9c34a30991..783ba5687d493 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexVersionTests.java @@ -154,6 +154,7 @@ public void testMax() { public void testMinimumCompatibleVersion() { assertThat(IndexVersion.getMinimumCompatibleIndexVersion(7170099), equalTo(IndexVersion.fromId(6000099))); assertThat(IndexVersion.getMinimumCompatibleIndexVersion(8000099), equalTo(IndexVersion.fromId(7000099))); + assertThat(IndexVersion.getMinimumCompatibleIndexVersion(9000099), equalTo(IndexVersion.fromId(8000099))); assertThat(IndexVersion.getMinimumCompatibleIndexVersion(10000000), equalTo(IndexVersion.fromId(9000000))); } From 662d81ea4f70b8e3804441c3a94e4ab130eaef22 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Fri, 13 Dec 2024 14:18:14 +0000 Subject: [PATCH 19/21] Revert "Remove unused versions" --- .../src/main/java/org/elasticsearch/index/IndexVersions.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index cb4f677fda423..0af1792299032 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -68,12 +68,17 @@ private static Version parseUnchecked(String version) { public static final IndexVersion V_7_4_0 = def(7_04_00_99, parseUnchecked("8.2.0")); public static final IndexVersion V_7_5_0 = def(7_05_00_99, parseUnchecked("8.3.0")); public static final IndexVersion V_7_6_0 = def(7_06_00_99, parseUnchecked("8.4.0")); + public static final IndexVersion V_7_7_0 = def(7_07_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_8_0 = def(7_08_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_9_0 = def(7_09_00_99, parseUnchecked("8.6.0")); public static final IndexVersion V_7_10_0 = def(7_10_00_99, parseUnchecked("8.7.0")); + public static final IndexVersion V_7_11_0 = def(7_11_00_99, parseUnchecked("8.7.0")); public static final IndexVersion V_7_12_0 = def(7_12_00_99, parseUnchecked("8.8.0")); + public static final IndexVersion V_7_13_0 = def(7_13_00_99, parseUnchecked("8.8.2")); + public static final IndexVersion V_7_14_0 = def(7_14_00_99, parseUnchecked("8.9.0")); public static final IndexVersion V_7_15_0 = def(7_15_00_99, parseUnchecked("8.9.0")); public static final IndexVersion V_7_16_0 = def(7_16_00_99, parseUnchecked("8.10.1")); + public static final IndexVersion V_7_17_0 = def(7_17_00_99, parseUnchecked("8.11.1")); public static final IndexVersion V_8_0_0 = def(8_00_00_99, Version.LUCENE_9_0_0); public static final IndexVersion V_8_1_0 = def(8_01_00_99, Version.LUCENE_9_0_0); public static final IndexVersion V_8_2_0 = def(8_02_00_99, Version.LUCENE_9_1_0); From 5ccd08e900cbd64b3e23735e3ce0551b3e573d41 Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Fri, 13 Dec 2024 14:20:58 +0000 Subject: [PATCH 20/21] Restore index versions --- server/src/main/java/org/elasticsearch/index/IndexVersions.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/index/IndexVersions.java b/server/src/main/java/org/elasticsearch/index/IndexVersions.java index 0af1792299032..255514c1e33fc 100644 --- a/server/src/main/java/org/elasticsearch/index/IndexVersions.java +++ b/server/src/main/java/org/elasticsearch/index/IndexVersions.java @@ -62,11 +62,13 @@ private static Version parseUnchecked(String version) { public static final IndexVersion ZERO = def(0, Version.LATEST); public static final IndexVersion V_7_0_0 = def(7_00_00_99, parseUnchecked("8.0.0")); + public static final IndexVersion V_7_1_0 = def(7_01_00_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_2_0 = def(7_02_00_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_2_1 = def(7_02_01_99, parseUnchecked("8.0.0")); public static final IndexVersion V_7_3_0 = def(7_03_00_99, parseUnchecked("8.1.0")); public static final IndexVersion V_7_4_0 = def(7_04_00_99, parseUnchecked("8.2.0")); public static final IndexVersion V_7_5_0 = def(7_05_00_99, parseUnchecked("8.3.0")); + public static final IndexVersion V_7_5_2 = def(7_05_02_99, parseUnchecked("8.3.0")); public static final IndexVersion V_7_6_0 = def(7_06_00_99, parseUnchecked("8.4.0")); public static final IndexVersion V_7_7_0 = def(7_07_00_99, parseUnchecked("8.5.1")); public static final IndexVersion V_7_8_0 = def(7_08_00_99, parseUnchecked("8.5.1")); From d4e3d3173d4d3e156d5384304c30fe8f1b8d360f Mon Sep 17 00:00:00 2001 From: alexey-ivanov-es Date: Mon, 16 Dec 2024 19:29:14 +0000 Subject: [PATCH 21/21] Revert "Remove unused system property" This reverts commit 2b63f8cb7809ea706e281f2882dfc1e243811c4a. --- .../compat/AbstractYamlRestCompatTestPlugin.java | 1 + .../test/junit/listeners/ReproduceInfoPrinter.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java index 73a1747ce73c1..b511702d1c7c3 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java @@ -242,6 +242,7 @@ public void apply(Project project) { // setup the test task TaskProvider yamlRestCompatTestTask = registerTestTask(project, yamlCompatTestSourceSet); yamlRestCompatTestTask.configure(testTask -> { + testTask.systemProperty("tests.restCompat", true); // Use test runner and classpath from "normal" yaml source set FileCollection outputFileCollection = yamlCompatTestSourceSet.getOutput(); testTask.setTestClassesDirs( diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index d73f446710458..b627a8803bf21 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -92,9 +92,21 @@ public void testFailure(Failure failure) throws Exception { GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b); gradleMessageBuilder.appendAllOpts(failure.getDescription()); + if (isRestApiCompatibilityTest()) { + b.append(System.lineSeparator()); + b.append( + "This is a Rest Api Compatibility Test. " + + "See the developers guide for details how to troubleshoot - " + + "https://github.com/elastic/elasticsearch/blob/master/REST_API_COMPATIBILITY.md" + ); + } printToErr(b.toString()); } + private static boolean isRestApiCompatibilityTest() { + return Boolean.parseBoolean(System.getProperty("tests.restCompat", "false")); + } + @SuppressForbidden(reason = "printing repro info") private static void printToErr(String s) { System.err.println(s);