Skip to content

Commit

Permalink
Cleanup BWC versions (opensearch-project#5311)
Browse files Browse the repository at this point in the history
Remove all checks put in place for BWC support of legacy ES versions. Cleanup old versions no longer supported.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
  • Loading branch information
adnapibar authored Nov 21, 2022
1 parent 66c5448 commit 94b8dfd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 216 deletions.
43 changes: 0 additions & 43 deletions .ci/bwcVersions
Original file line number Diff line number Diff line change
@@ -1,47 +1,4 @@
BWC_VERSION:
- "7.0.0"
- "7.0.1"
- "7.1.0"
- "7.1.1"
- "7.2.0"
- "7.2.1"
- "7.3.0"
- "7.3.1"
- "7.3.2"
- "7.4.0"
- "7.4.1"
- "7.4.2"
- "7.5.0"
- "7.5.1"
- "7.5.2"
- "7.6.0"
- "7.6.1"
- "7.6.2"
- "7.7.0"
- "7.7.1"
- "7.8.0"
- "7.8.1"
- "7.9.0"
- "7.9.1"
- "7.9.2"
- "7.9.3"
- "7.10.0"
- "7.10.1"
- "7.10.2"
- "1.0.0"
- "1.1.0"
- "1.2.0"
- "1.2.1"
- "1.2.2"
- "1.2.3"
- "1.2.4"
- "1.2.5"
- "1.3.0"
- "1.3.1"
- "1.3.2"
- "1.3.3"
- "1.3.4"
- "1.3.5"
- "2.0.0"
- "2.0.1"
- "2.0.2"
Expand Down
64 changes: 11 additions & 53 deletions buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class BwcVersions {
private final Map<Integer, List<Version>> groupByMajor;
private final Map<Version, UnreleasedVersionInfo> unreleased;

public class UnreleasedVersionInfo {
public static class UnreleasedVersionInfo {
public final Version version;
public final String branch;
public final String gradleProjectPath;
Expand Down Expand Up @@ -149,13 +149,7 @@ public BwcVersions(SortedSet<Version> allVersions, Version currentVersionPropert

groupByMajor = allVersions.stream()
// We only care about the last 2 majors when it comes to BWC.
// It might take us time to remove the older ones from versionLines, so we allow them to exist.
// Adjust the major number since OpenSearch 1.x is released after predecessor version 7.x
.filter(
version -> (version.getMajor() == 1 ? 7 : version.getMajor()) > (currentVersion.getMajor() == 1
? 7
: currentVersion.getMajor()) - 2
)
.filter(version -> version.getMajor() > currentVersion.getMajor() - 2)
.collect(Collectors.groupingBy(Version::getMajor, Collectors.toList()));

assertCurrentVersionMatchesParsed(currentVersionProperty);
Expand All @@ -174,9 +168,7 @@ public BwcVersions(SortedSet<Version> allVersions, Version currentVersionPropert

private void assertNoOlderThanTwoMajors() {
Set<Integer> majors = groupByMajor.keySet();
// until OpenSearch 3.0 we will need to carry three major support
// (1, 7, 6) && (2, 1, 7) since OpenSearch 1.0 === Legacy 7.x
int numSupportedMajors = (currentVersion.getMajor() < 3) ? 3 : 2;
int numSupportedMajors = 2;
if (majors.size() != numSupportedMajors && currentVersion.getMinor() != 0 && currentVersion.getRevision() != 0) {
throw new IllegalStateException("Expected exactly 2 majors in parsed versions but found: " + majors);
}
Expand Down Expand Up @@ -207,7 +199,7 @@ public void forPreviousUnreleased(Consumer<UnreleasedVersionInfo> consumer) {
.map(version -> new UnreleasedVersionInfo(version, getBranchFor(version), getGradleProjectPathFor(version)))
.collect(Collectors.toList());

collect.forEach(uvi -> consumer.accept(uvi));
collect.forEach(consumer);
}

private String getGradleProjectPathFor(Version version) {
Expand Down Expand Up @@ -271,18 +263,9 @@ public List<Version> getUnreleased() {
// The current version is being worked, is always unreleased
unreleased.add(currentVersion);

// No unreleased versions for 1.0.0
// todo remove this hack
if (currentVersion.equals(Version.fromString("1.0.0"))) {
return unmodifiableList(unreleased);
}

// the tip of the previous major is unreleased for sure, be it a minor or a bugfix
if (currentVersion.getMajor() != 1) {
final Version latestOfPreviousMajor = getLatestVersionByKey(
this.groupByMajor,
currentVersion.getMajor() == 1 ? 7 : currentVersion.getMajor() - 1
);
final Version latestOfPreviousMajor = getLatestVersionByKey(this.groupByMajor, currentVersion.getMajor() - 1);
unreleased.add(latestOfPreviousMajor);
if (latestOfPreviousMajor.getRevision() == 0) {
// if the previous major is a x.y.0 release, then the tip of the minor before that (y-1) is also unreleased
Expand Down Expand Up @@ -311,7 +294,7 @@ public List<Version> getUnreleased() {
}
}

return unmodifiableList(unreleased.stream().sorted().distinct().collect(Collectors.toList()));
return unreleased.stream().sorted().distinct().collect(Collectors.toUnmodifiableList());
}

private Version getLatestInMinor(int major, int minor) {
Expand Down Expand Up @@ -342,7 +325,7 @@ private Map<Integer, List<Version>> getReleasedMajorGroupedByMinor() {

public void compareToAuthoritative(List<Version> authoritativeReleasedVersions) {
Set<Version> notReallyReleased = new HashSet<>(getReleased());
notReallyReleased.removeAll(authoritativeReleasedVersions);
authoritativeReleasedVersions.forEach(notReallyReleased::remove);
if (notReallyReleased.isEmpty() == false) {
throw new IllegalStateException(
"out-of-date released versions"
Expand Down Expand Up @@ -370,32 +353,21 @@ private List<Version> getReleased() {
.stream()
.flatMap(Collection::stream)
.filter(each -> unreleased.contains(each) == false)
// this is to make sure we only consider OpenSearch versions
// TODO remove this filter once legacy ES versions are no longer supported
.filter(v -> v.onOrAfter("1.0.0"))
.collect(Collectors.toList());
}

public List<Version> getIndexCompatible() {
int currentMajor = currentVersion.getMajor();
int prevMajor = getPreviousMajor(currentMajor);
List<Version> result = Stream.concat(groupByMajor.get(prevMajor).stream(), groupByMajor.get(currentMajor).stream())
return Stream.concat(groupByMajor.get(prevMajor).stream(), groupByMajor.get(currentMajor).stream())
.filter(version -> version.equals(currentVersion) == false)
.collect(Collectors.toList());
if (currentMajor == 1) {
// add 6.x compatible for OpenSearch 1.0.0
return unmodifiableList(Stream.concat(groupByMajor.get(prevMajor - 1).stream(), result.stream()).collect(Collectors.toList()));
} else if (currentMajor == 2) {
// add 7.x compatible for OpenSearch 2.0.0
return unmodifiableList(Stream.concat(groupByMajor.get(7).stream(), result.stream()).collect(Collectors.toList()));
}
return unmodifiableList(result);
.collect(Collectors.toUnmodifiableList());
}

public List<Version> getWireCompatible() {
List<Version> wireCompat = new ArrayList<>();
int currentMajor = currentVersion.getMajor();
int lastMajor = currentMajor == 1 ? 6 : currentMajor == 2 ? 7 : currentMajor - 1;
int lastMajor = currentMajor - 1;
List<Version> lastMajorList = groupByMajor.get(lastMajor);
if (lastMajorList == null) {
throw new IllegalStateException("Expected to find a list of versions for version: " + lastMajor);
Expand All @@ -405,20 +377,6 @@ public List<Version> getWireCompatible() {
wireCompat.add(lastMajorList.get(i));
}

// if current is OpenSearch 1.0.0 add all of the 7.x line:
if (currentMajor == 1) {
List<Version> previousMajor = groupByMajor.get(7);
for (Version v : previousMajor) {
wireCompat.add(v);
}
} else if (currentMajor == 2) {
// add all of the 1.x line:
List<Version> previousMajor = groupByMajor.get(1);
for (Version v : previousMajor) {
wireCompat.add(v);
}
}

wireCompat.addAll(groupByMajor.get(currentMajor));
wireCompat.remove(currentVersion);
wireCompat.sort(Version::compareTo);
Expand All @@ -438,7 +396,7 @@ public List<Version> getUnreleasedWireCompatible() {
}

private int getPreviousMajor(int currentMajor) {
return currentMajor == 1 ? 7 : currentMajor - 1;
return currentMajor - 1;
}

}

This file was deleted.

3 changes: 0 additions & 3 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ apply plugin: 'opensearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"

for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
if (bwcVersion.before('6.3.0')) {
continue;
}
String baseName = "v${bwcVersion}"

testClusters {
Expand Down
27 changes: 8 additions & 19 deletions qa/repository-multi-version/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ dependencies {
}

for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
if (bwcVersion.before('6.3.0')) {
continue;
}
String baseName = "v${bwcVersion}"
String oldClusterName = "${baseName}-old"
String newClusterName = "${baseName}-new"
Expand Down Expand Up @@ -76,28 +73,20 @@ for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
systemProperty 'tests.rest.suite', 'step2'
}

// Step 3 and Step 4 registered for versions for OpenSearch
// since the ES cluster would not be able to read snapshots from OpenSearch cluster in Step 3.
if (bwcVersion.after('7.10.2')) {
tasks.register("${baseName}#Step3OldClusterTest", StandaloneRestIntegTestTask) {
tasks.register("${baseName}#Step3OldClusterTest", StandaloneRestIntegTestTask) {
useCluster testClusters."${oldClusterName}"
dependsOn "${baseName}#Step2NewClusterTest"
systemProperty 'tests.rest.suite', 'step3'
}

tasks.register("${baseName}#Step4NewClusterTest", StandaloneRestIntegTestTask) {
useCluster testClusters."${newClusterName}"
dependsOn "${baseName}#Step3OldClusterTest"
systemProperty 'tests.rest.suite', 'step4'
}
tasks.register("${baseName}#Step4NewClusterTest", StandaloneRestIntegTestTask) {
useCluster testClusters."${newClusterName}"
dependsOn "${baseName}#Step3OldClusterTest"
systemProperty 'tests.rest.suite', 'step4'
}

tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#Step4NewClusterTest")
}
} else {
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#Step2NewClusterTest")
}
tasks.register(bwcTaskName(bwcVersion)) {
dependsOn tasks.named("${baseName}#Step4NewClusterTest")
}

tasks.matching { it.name.startsWith(baseName) && it.name.endsWith("ClusterTest") }.configureEach {
Expand Down
3 changes: 0 additions & 3 deletions qa/verify-version-constants/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ apply plugin: 'opensearch.standalone-test'
apply from : "$rootDir/gradle/bwc-test.gradle"

for (Version bwcVersion : BuildParams.bwcVersions.indexCompatible) {
if (bwcVersion.before('6.3.0')) {
continue;
}
String baseName = "v${bwcVersion}"

testClusters {
Expand Down

0 comments on commit 94b8dfd

Please sign in to comment.