diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchException.java b/server/src/main/java/org/elasticsearch/ElasticsearchException.java index 260b443a6a557..51662414e0d07 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/server/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -1027,7 +1027,7 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.index.shard.ShardNotInPrimaryModeException.class, org.elasticsearch.index.shard.ShardNotInPrimaryModeException::new, 155, - Version.V_6_8_1); + UNKNOWN_VERSION_ADDED); final Class exceptionClass; final CheckedFunction constructor; diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index ec79c17a834f1..18dcd192efa72 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -46,10 +46,6 @@ public class Version implements Comparable, ToXContentFragment { */ public static final int V_EMPTY_ID = 0; public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST); - public static final int V_6_8_0_ID = 6080099; - public static final Version V_6_8_0 = new Version(V_6_8_0_ID, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final int V_6_8_1_ID = 6080199; - public static final Version V_6_8_1 = new Version(V_6_8_1_ID, org.apache.lucene.util.Version.LUCENE_7_7_0); public static final int V_7_0_0_ID = 7000099; public static final Version V_7_0_0 = new Version(V_7_0_0_ID, org.apache.lucene.util.Version.LUCENE_8_0_0); public static final int V_7_0_1_ID = 7000199; @@ -96,10 +92,6 @@ public static Version fromId(int id) { return V_7_0_1; case V_7_0_0_ID: return V_7_0_0; - case V_6_8_1_ID: - return V_6_8_1; - case V_6_8_0_ID: - return V_6_8_0; case V_EMPTY_ID: return V_EMPTY; default: @@ -283,8 +275,11 @@ public Version minimumCompatibilityVersion() { if (major == 6) { // force the minimum compatibility for version 6 to 5.6 since we don't reference version 5 anymore return Version.fromId(5060099); - } else if (major >= 7) { - // all major versions from 7 onwards are compatible with last minor series of the previous major + } else if (major == 7) { + // force the minimum compatibility for version 7 to 6.8 since we don't reference version 6 anymore + return Version.fromId(6080099); + } else if (major >= 8) { + // all major versions from 8 onwards are compatible with last minor series of the previous major Version bwcVersion = null; for (int i = DeclaredVersionsHolder.DECLARED_VERSIONS.size() - 1; i >= 0; i--) { diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index eb57964af4dc4..79d50fff2ac51 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -186,7 +186,7 @@ public void testMinCompatVersion() { // from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is // released since we need to bump the supported minor in Version#minimumCompatibilityVersion() - Version lastVersion = Version.V_6_8_0; // TODO: remove this once min compat version is a constant instead of method + Version lastVersion = Version.fromString("6.8.0"); // TODO: remove this once min compat version is a constant instead of method assertEquals(lastVersion.major, Version.V_7_0_0.minimumCompatibilityVersion().major); assertEquals("did you miss to bump the minor in Version#minimumCompatibilityVersion()", lastVersion.minor, Version.V_7_0_0.minimumCompatibilityVersion().minor); @@ -345,7 +345,7 @@ public static void assertUnknownVersion(Version version) { public void testIsCompatible() { assertTrue(isCompatible(Version.CURRENT, Version.CURRENT.minimumCompatibilityVersion())); - assertFalse(isCompatible(Version.fromString("6.7.0"), Version.fromString("7.0.0"))); + assertFalse(isCompatible(Version.V_7_0_0, Version.V_8_0_0)); assertTrue(isCompatible(Version.fromString("6.8.0"), Version.fromString("7.0.0"))); assertFalse(isCompatible(Version.fromId(2000099), Version.V_7_0_0)); assertFalse(isCompatible(Version.fromId(2000099), Version.fromString("6.5.0"))); diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/JoinTaskExecutorTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/JoinTaskExecutorTests.java index b8168ce3de4a7..0225ffe8fe6cd 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/JoinTaskExecutorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/JoinTaskExecutorTests.java @@ -54,8 +54,7 @@ public void testPreventJoinClusterWithUnsupportedIndices() { Settings.builder().build(); MetaData.Builder metaBuilder = MetaData.builder(); IndexMetaData indexMetaData = IndexMetaData.builder("test") - .settings(settings(VersionUtils.getPreviousVersion(Version.CURRENT - .minimumIndexCompatibilityVersion()))) + .settings(settings(Version.fromString("6.8.0"))) // latest V6 released version .numberOfShards(1) .numberOfReplicas(1).build(); metaBuilder.put(indexMetaData, false); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java index 3de716acfee44..cda92d3953ea3 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java @@ -433,12 +433,6 @@ public void testCalculateNumRoutingShards() { assertEquals(2048, MetaDataCreateIndexService.calculateNumRoutingShards(1024, Version.CURRENT)); assertEquals(4096, MetaDataCreateIndexService.calculateNumRoutingShards(2048, Version.CURRENT)); - Version latestV6 = VersionUtils.getPreviousVersion(Version.V_7_0_0); - int numShards = randomIntBetween(1, 1000); - assertEquals(numShards, MetaDataCreateIndexService.calculateNumRoutingShards(numShards, latestV6)); - assertEquals(numShards, MetaDataCreateIndexService.calculateNumRoutingShards(numShards, - VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), latestV6))); - for (int i = 0; i < 1000; i++) { int randomNumShards = randomIntBetween(1, 10000); int numRoutingShards = MetaDataCreateIndexService.calculateNumRoutingShards(randomNumShards, Version.CURRENT); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java index 768bc38813c0b..47c686e0c87a2 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/SecurityTests.java @@ -318,29 +318,6 @@ public void testJoinValidatorForFIPSLicense() throws Exception { } } - public void testIndexJoinValidator_Old_And_Rolling() throws Exception { - createComponents(Settings.EMPTY); - BiConsumer joinValidator = security.getJoinValidator(); - assertNotNull(joinValidator); - Version version = VersionUtils.randomVersionBetween(random(), VersionUtils.getFirstVersion(), - VersionUtils.getPreviousVersion(Version.V_7_0_0)); - DiscoveryNode node = new DiscoveryNode("foo", buildNewFakeTransportAddress(), Version.CURRENT); - IndexMetaData indexMetaData = IndexMetaData.builder(SECURITY_MAIN_ALIAS) - .settings(settings(version) - .put(INDEX_FORMAT_SETTING.getKey(), INTERNAL_MAIN_INDEX_FORMAT - 1)) - .numberOfShards(1).numberOfReplicas(0) - .build(); - DiscoveryNode existingOtherNode = new DiscoveryNode("bar", buildNewFakeTransportAddress(), version); - DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(existingOtherNode).build(); - ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) - .nodes(discoveryNodes) - .metaData(MetaData.builder().put(indexMetaData, true).build()).build(); - IllegalStateException e = expectThrows(IllegalStateException.class, - () -> joinValidator.accept(node, clusterState)); - assertThat(e.getMessage(), equalTo("Security index is not on the current version [6] - " + - "The Upgrade API must be run for 7.x nodes to join the cluster")); - } - public void testIndexJoinValidator_FullyCurrentCluster() throws Exception { createComponents(Settings.EMPTY); BiConsumer joinValidator = security.getJoinValidator();