Skip to content

remove v6.8.x version constant and the backcompat code that uses it #42146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends ElasticsearchException> exceptionClass;
final CheckedFunction<StreamInput, ? extends ElasticsearchException, IOException> constructor;
Expand Down
15 changes: 5 additions & 10 deletions server/src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public class Version implements Comparable<Version>, 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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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--) {
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/java/org/elasticsearch/VersionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,29 +318,6 @@ public void testJoinValidatorForFIPSLicense() throws Exception {
}
}

public void testIndexJoinValidator_Old_And_Rolling() throws Exception {
createComponents(Settings.EMPTY);
BiConsumer<DiscoveryNode, ClusterState> 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"));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this test as Security index is not on the version 6


public void testIndexJoinValidator_FullyCurrentCluster() throws Exception {
createComponents(Settings.EMPTY);
BiConsumer<DiscoveryNode, ClusterState> joinValidator = security.getJoinValidator();
Expand Down