Skip to content

Commit

Permalink
Remove OSS specific distribution packaging (elastic#69775)
Browse files Browse the repository at this point in the history
* Remove OSS projects from distribution packaging
* Remove OSS flavor from ElasticsearchDistribution
* Remove OSS handling from docker build setup
  • Loading branch information
breskeby authored Mar 3, 2021
1 parent 093e78d commit 24adbbc
Show file tree
Hide file tree
Showing 35 changed files with 119 additions and 478 deletions.
6 changes: 0 additions & 6 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,10 @@ if (project != rootProject) {
dependencies {
reaper project('reaper')
distribution project(':distribution:archives:windows-zip')
distribution project(':distribution:archives:oss-windows-zip')
distribution project(':distribution:archives:darwin-tar')
distribution project(':distribution:archives:darwin-aarch64-tar')
distribution project(':distribution:archives:oss-darwin-tar')
distribution project(':distribution:archives:oss-darwin-aarch64-tar')
distribution project(':distribution:archives:linux-aarch64-tar')
distribution project(':distribution:archives:linux-tar')
distribution project(':distribution:archives:oss-linux-tar')
distribution project(':distribution:archives:oss-linux-aarch64-tar')

integTestRuntimeOnly(project(":libs:elasticsearch-core"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.elasticsearch.gradle;

import org.elasticsearch.gradle.ElasticsearchDistribution.Flavor;
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
import org.elasticsearch.gradle.ElasticsearchDistribution.Type;
import org.elasticsearch.gradle.docker.DockerSupportPlugin;
Expand Down Expand Up @@ -177,12 +176,7 @@ private String dependencyNotation(ElasticsearchDistribution distribution) {
} else if (distribution.getType() == Type.DEB) {
classifier = ":amd64";
}
String flavor = "";
if (distribution.getFlavor() == Flavor.OSS && distroVersion.onOrAfter("6.3.0")) {
flavor = "-oss";
}

String group = distribution.getVersion().endsWith("-SNAPSHOT") ? FAKE_SNAPSHOT_IVY_GROUP : FAKE_IVY_GROUP;
return group + ":elasticsearch" + flavor + ":" + distribution.getVersion() + classifier + "@" + extension;
return group + ":elasticsearch" + ":" + distribution.getVersion() + classifier + "@" + extension;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ public boolean shouldExtract() {
}
}

public enum Flavor {
DEFAULT,
OSS;

@Override
public String toString() {
return super.toString().toLowerCase(Locale.ROOT);
}
}

// package private to tests can use
public static final Platform CURRENT_PLATFORM = OS.<Platform>conditional()
.onLinux(() -> Platform.LINUX)
Expand All @@ -89,7 +79,6 @@ public String toString() {
private final Property<String> version;
private final Property<Type> type;
private final Property<Platform> platform;
private final Property<Flavor> flavor;
private final Property<Boolean> bundledJdk;
private final Property<Boolean> failIfUnavailable;
private final Configuration extracted;
Expand All @@ -112,7 +101,6 @@ public String toString() {
this.type = objectFactory.property(Type.class);
this.type.convention(Type.ARCHIVE);
this.platform = objectFactory.property(Platform.class);
this.flavor = objectFactory.property(Flavor.class);
this.bundledJdk = objectFactory.property(Boolean.class);
this.failIfUnavailable = objectFactory.property(Boolean.class).convention(true);
this.extracted = extractedConfiguration;
Expand Down Expand Up @@ -148,14 +136,6 @@ public void setType(Type type) {
this.type.set(type);
}

public Flavor getFlavor() {
return flavor.getOrNull();
}

public void setFlavor(Flavor flavor) {
this.flavor.set(flavor);
}

public boolean getBundledJdk() {
return bundledJdk.getOrElse(true);
}
Expand Down Expand Up @@ -252,11 +232,6 @@ void finalizeValues() {
"platform cannot be set on elasticsearch distribution [" + name + "] of type [integ_test_zip]"
);
}
if (flavor.getOrNull() != null) {
throw new IllegalArgumentException(
"flavor [" + flavor.get() + "] not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]"
);
}
if (bundledJdk.getOrNull() != null) {
throw new IllegalArgumentException(
"bundledJdk cannot be set on elasticsearch distribution [" + name + "] of type [integ_test_zip]"
Expand Down Expand Up @@ -288,23 +263,16 @@ void finalizeValues() {
"bundledJdk cannot be set on elasticsearch distribution [" + name + "] of type " + "[docker]"
);
}
if (flavor.get() == Flavor.OSS && type.get() == Type.DOCKER_UBI) {
throw new IllegalArgumentException("Cannot build a UBI docker image for the OSS distribution");
}
}
}

if (flavor.isPresent() == false) {
flavor.set(Flavor.DEFAULT);
}
if (bundledJdk.isPresent() == false) {
bundledJdk.set(true);
}

version.finalizeValue();
platform.finalizeValue();
type.finalizeValue();
flavor.finalizeValue();
bundledJdk.finalizeValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ private static String distributionProjectName(ElasticsearchDistribution distribu
? ""
: "-" + architecture.toString().toLowerCase();

if (distribution.getFlavor() == ElasticsearchDistribution.Flavor.OSS) {
projectName += "oss-";
}

if (distribution.getBundledJdk() == false) {
projectName += "no-jdk-";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.elasticsearch.gradle.Architecture;
import org.elasticsearch.gradle.DistributionDownloadPlugin;
import org.elasticsearch.gradle.ElasticsearchDistribution;
import org.elasticsearch.gradle.ElasticsearchDistribution.Flavor;
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
import org.elasticsearch.gradle.ElasticsearchDistribution.Type;
import org.elasticsearch.gradle.Jdk;
Expand Down Expand Up @@ -98,7 +97,6 @@ public void apply(Project project) {
Map<Type, List<TaskProvider<Test>>> linuxTestTasks = new HashMap<>();
Map<String, List<TaskProvider<Test>>> upgradeTestTasks = new HashMap<>();
Map<String, TaskProvider<?>> depsTasks = new HashMap<>();

for (ElasticsearchDistribution distribution : testDistributions) {
String taskname = destructiveDistroTestTaskName(distribution);
TaskProvider<?> depsTask = project.getTasks().register(taskname + "#deps");
Expand All @@ -123,9 +121,6 @@ public void apply(Project project) {

if ((distribution.getType() == Type.DEB || distribution.getType() == Type.RPM) && distribution.getBundledJdk()) {
for (Version version : BuildParams.getBwcVersions().getIndexCompatible()) {
if (distribution.getFlavor() == Flavor.OSS && version.before("6.3.0")) {
continue; // before opening xpack
}
final ElasticsearchDistribution bwcDistro;
if (version.equals(Version.fromString(distribution.getVersion()))) {
// this is the same as the distribution we are testing
Expand All @@ -136,7 +131,6 @@ public void apply(Project project) {
distribution.getArchitecture(),
distribution.getType(),
distribution.getPlatform(),
distribution.getFlavor(),
distribution.getBundledJdk(),
version.toString()
);
Expand Down Expand Up @@ -228,7 +222,6 @@ public void apply(Project project) {

private static Map<ElasticsearchDistribution.Type, TaskProvider<?>> lifecycleTasks(Project project, String taskPrefix) {
Map<ElasticsearchDistribution.Type, TaskProvider<?>> lifecyleTasks = new HashMap<>();

lifecyleTasks.put(Type.DOCKER, project.getTasks().register(taskPrefix + ".docker"));
lifecyleTasks.put(Type.DOCKER_UBI, project.getTasks().register(taskPrefix + ".ubi"));
lifecyleTasks.put(Type.ARCHIVE, project.getTasks().register(taskPrefix + ".archives"));
Expand Down Expand Up @@ -369,54 +362,36 @@ private List<ElasticsearchDistribution> configureDistributions(Project project)

for (Architecture architecture : Architecture.values()) {
for (Type type : List.of(Type.DEB, Type.RPM, Type.DOCKER, Type.DOCKER_UBI)) {
for (Flavor flavor : Flavor.values()) {
for (boolean bundledJdk : Arrays.asList(true, false)) {
if (bundledJdk == false) {
// We'll never publish an ARM (aarch64) build without a bundled JDK.
if (architecture == Architecture.AARCH64) {
continue;
}
// All our Docker images include a bundled JDK so it doesn't make sense to test without one.
if (type == Type.DOCKER || type == Type.DOCKER_UBI) {
continue;
}
for (boolean bundledJdk : Arrays.asList(true, false)) {
if (bundledJdk == false) {
// We'll never publish an ARM (aarch64) build without a bundled JDK.
if (architecture == Architecture.AARCH64) {
continue;
}

// We don't publish the OSS distribution on UBI
if (type == Type.DOCKER_UBI && flavor == Flavor.OSS) {
// All our Docker images include a bundled JDK so it doesn't make sense to test without one.
if (type == Type.DOCKER || type == Type.DOCKER_UBI) {
continue;
}

currentDistros.add(
createDistro(distributions, architecture, type, null, flavor, bundledJdk, VersionProperties.getElasticsearch())
);
}
currentDistros.add(
createDistro(distributions, architecture, type, null, bundledJdk, VersionProperties.getElasticsearch())
);
}
}
}

for (Architecture architecture : Architecture.values()) {
for (Platform platform : Arrays.asList(Platform.LINUX, Platform.WINDOWS)) {
for (Flavor flavor : Flavor.values()) {
for (boolean bundledJdk : Arrays.asList(true, false)) {
if (bundledJdk == false && architecture != Architecture.X64) {
// We will never publish distributions for non-x86 (amd64) platforms
// without a bundled JDK
continue;
}

currentDistros.add(
createDistro(
distributions,
architecture,
Type.ARCHIVE,
platform,
flavor,
bundledJdk,
VersionProperties.getElasticsearch()
)
);
for (boolean bundledJdk : Arrays.asList(true, false)) {
if (bundledJdk == false && architecture != Architecture.X64) {
// We will never publish distributions for non-x86 (amd64) platforms
// without a bundled JDK
continue;
}

currentDistros.add(
createDistro(distributions, architecture, Type.ARCHIVE, platform, bundledJdk, VersionProperties.getElasticsearch())
);
}
}
}
Expand All @@ -429,15 +404,13 @@ private static ElasticsearchDistribution createDistro(
Architecture architecture,
Type type,
Platform platform,
Flavor flavor,
boolean bundledJdk,
String version
) {
String name = distroId(type, platform, flavor, bundledJdk, architecture) + "-" + version;
String name = distroId(type, platform, bundledJdk, architecture) + "-" + version;
boolean isDocker = type == Type.DOCKER || type == Type.DOCKER_UBI;
ElasticsearchDistribution distro = distributions.create(name, d -> {
d.setArchitecture(architecture);
d.setFlavor(flavor);
d.setType(type);
if (type == Type.ARCHIVE) {
d.setPlatform(platform);
Expand All @@ -462,9 +435,8 @@ private static boolean isWindows(Project project) {
return project.getName().contains("windows");
}

private static String distroId(Type type, Platform platform, Flavor flavor, boolean bundledJdk, Architecture architecture) {
return flavor
+ "-"
private static String distroId(Type type, Platform platform, boolean bundledJdk, Architecture architecture) {
return "default-"
+ (type == Type.ARCHIVE ? platform + "-" : "")
+ type
+ (bundledJdk ? "" : "-no-jdk")
Expand All @@ -473,16 +445,15 @@ private static String distroId(Type type, Platform platform, Flavor flavor, bool

private static String destructiveDistroTestTaskName(ElasticsearchDistribution distro) {
Type type = distro.getType();
return "destructiveDistroTest."
+ distroId(type, distro.getPlatform(), distro.getFlavor(), distro.getBundledJdk(), distro.getArchitecture());
return "destructiveDistroTest." + distroId(type, distro.getPlatform(), distro.getBundledJdk(), distro.getArchitecture());
}

private static String destructiveDistroUpgradeTestTaskName(ElasticsearchDistribution distro, String bwcVersion) {
Type type = distro.getType();
return "destructiveDistroUpgradeTest.v"
+ bwcVersion
+ "."
+ distroId(type, distro.getPlatform(), distro.getFlavor(), distro.getBundledJdk(), distro.getArchitecture());
+ distroId(type, distro.getPlatform(), distro.getBundledJdk(), distro.getArchitecture());
}

private static void addDistributionSysprop(Test task, String sysprop, Supplier<String> valueSupplier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,10 @@ private void setDistributionType(ElasticsearchDistribution distribution, TestDis
if (testDistribution == TestDistribution.INTEG_TEST) {
distribution.setType(ElasticsearchDistribution.Type.INTEG_TEST_ZIP);
// we change the underlying distribution when changing the test distribution of the cluster.
distribution.setFlavor(null);
distribution.setPlatform(null);
distribution.setBundledJdk(null);
} else {
distribution.setType(ElasticsearchDistribution.Type.ARCHIVE);
if (testDistribution == TestDistribution.DEFAULT) {
distribution.setFlavor(ElasticsearchDistribution.Flavor.DEFAULT);
} else {
distribution.setFlavor(ElasticsearchDistribution.Flavor.OSS);
}
}
}

Expand Down
Loading

0 comments on commit 24adbbc

Please sign in to comment.