Skip to content

Commit

Permalink
Renaming CPU architecture to have consistent naming (opensearch-proje…
Browse files Browse the repository at this point in the history
…ct#612)

* Renaming CPU architecture from x86_64, aarch64 to x64, arm64

Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
  • Loading branch information
saratvemulapalli authored Apr 26, 2021
1 parent c5a3c3c commit 0e9f74e
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 88 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ if (project != rootProject) {
distribution project(':distribution:archives:windows-zip')
distribution project(':distribution:archives:darwin-tar')
distribution project(':distribution:archives:linux-tar')
distribution project(':distribution:archives:linux-aarch64-tar')
distribution project(':distribution:archives:linux-arm64-tar')

integTestRuntimeOnly(project(":libs:opensearch-core"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {

then:
result.tasks.size() == 3
result.output.count("Unpacking opensearch-${version}-linux-x86_64.tar.gz " +
result.output.count("Unpacking opensearch-${version}-linux-x64.tar.gz " +
"using SymbolicLinkPreservingUntarTransform.") == 1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DistributionDownloadFixture {
private static String urlPath(String version, OpenSearchDistribution.Platform platform) {
String fileType = ((platform == OpenSearchDistribution.Platform.LINUX ||
platform == OpenSearchDistribution.Platform.DARWIN)) ? "tar.gz" : "zip"
"/releases/core/opensearch/${version}/opensearch-${version}-${platform}-x86_64.$fileType"
"/releases/core/opensearch/${version}/opensearch-${version}-${platform}-x64.$fileType"
}

private static byte[] filebytes(String urlPath) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGradleFuncTest
result.output.contains("[8.0.1] > Task :distribution:archives:darwin-tar:assemble")
normalizedOutput(result.output)
.contains("distfile /distribution/bwc/bugfix/build/bwc/checkout-8.0/distribution/archives/darwin-tar/" +
"build/distributions/opensearch-8.0.1-SNAPSHOT-darwin-x86_64.tar.gz")
"build/distributions/opensearch-8.0.1-SNAPSHOT-darwin-x64.tar.gz")
}

def "bwc expanded distribution folder can be resolved as bwc project artifact"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ subprojects {
destinationDirectory.set(file('build/distributions'))
archiveBaseName.set("opensearch")
archiveVersion.set("8.0.1-SNAPSHOT")
archiveClassifier.set("darwin-x86_64")
archiveClassifier.set("darwin-x64")
archiveExtension.set('tar.gz')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class ClusterFormationTasks {

Version version = Version.fromString(opensearchVersion)
String os = getOs()
String classifier = "-${os}-x86_64"
String classifier = "-${os}-x64"
String packaging = os.equals('windows') ? 'zip' : 'tar.gz'
String artifactName = 'opensearch'
Object dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public enum Architecture {

X64,
AARCH64;
ARM64;

public static Architecture current() {
final String architecture = System.getProperty("os.arch", "");
Expand All @@ -44,7 +44,7 @@ public static Architecture current() {
case "x86_64":
return X64;
case "aarch64":
return AARCH64;
return ARM64;
default:
throw new IllegalArgumentException("can not determine architecture from [" + architecture + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ private String dependencyNotation(OpenSearchDistribution distribution) {

Version distroVersion = Version.fromString(distribution.getVersion());
String extension = distribution.getType().toString();
String classifier = ":x86_64";
String classifier = ":x64";
if (distribution.getType() == Type.ARCHIVE) {
extension = distribution.getPlatform() == Platform.WINDOWS ? "zip" : "tar.gz";
if (distroVersion.onOrAfter("7.0.0")) {
classifier = ":" + distribution.getPlatform() + "-x86_64";
classifier = ":" + distribution.getPlatform() + "-x64";
} else {
classifier = "";
}
Expand Down
12 changes: 10 additions & 2 deletions buildSrc/src/main/java/org/opensearch/gradle/Jdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ public String getArchitecture() {
}

public void setArchitecture(final String architecture) {
if (ALLOWED_ARCHITECTURES.contains(architecture) == false) {
String jdkArchitecture = translateJdkArchitecture(architecture);
if (ALLOWED_ARCHITECTURES.contains(jdkArchitecture) == false) {
throw new IllegalArgumentException(
"unknown architecture [" + architecture + "] for jdk [" + name + "], must be one of " + ALLOWED_ARCHITECTURES
"unknown architecture [" + jdkArchitecture + "] for jdk [" + name + "], must be one of " + ALLOWED_ARCHITECTURES
);
}
this.architecture.set(architecture);
Expand Down Expand Up @@ -229,4 +230,11 @@ private void parseVersion(String version) {
hash = jdkVersionMatcher.group(5);
}

private String translateJdkArchitecture(String architecture) {
/*
* Jdk uses aarch64 from ARM. Translating from arm64 to aarch64 which Jdk understands.
*/
return architecture == "arm64" ? "aarch64" : architecture;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void registerDistributionArchiveArtifact(Project bwcProject, Distributio
String artifactName = "opensearch";

String suffix = artifactFileName.endsWith("tar.gz") ? "tar.gz" : artifactFileName.substring(artifactFileName.length() - 3);
int archIndex = artifactFileName.indexOf("x86_64");
int archIndex = artifactFileName.indexOf("x64");

bwcProject.getConfigurations().create(distributionProject.name);
bwcProject.getArtifacts().add(distributionProject.name, distributionProject.getDistFile(), artifact -> {
Expand All @@ -146,7 +146,7 @@ private void registerDistributionArchiveArtifact(Project bwcProject, Distributio
String classifier = "";
if (archIndex != -1) {
int osIndex = artifactFileName.lastIndexOf('-', archIndex - 2);
classifier = "-" + artifactFileName.substring(osIndex + 1, archIndex - 1) + "-x86_64";
classifier = "-" + artifactFileName.substring(osIndex + 1, archIndex - 1) + "-x64";
}
artifact.setClassifier(classifier);
});
Expand All @@ -171,15 +171,15 @@ private static List<DistributionProject> resolveArchiveProjects(File checkoutDir
if (name.contains("zip") || name.contains("tar")) {
int index = name.lastIndexOf('-');
String baseName = name.substring(0, index);
classifier = "-" + baseName + "-x86_64";
classifier = "-" + baseName + "-x64";
extension = name.substring(index + 1);
if (extension.equals("tar")) {
extension += ".gz";
}
} else if (name.contains("deb")) {
classifier = "-amd64";
} else if (name.contains("rpm")) {
classifier = "-x86_64";
classifier = "-x64";
}
} else {
extension = name.substring(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ private List<OpenSearchDistribution> configureDistributions(Project project) {
)) {
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) {
// We'll never publish an ARM (arm64) build without a bundled JDK.
if (architecture == Architecture.ARM64) {
continue;
}
// All our Docker images include a bundled JDK so it doesn't make sense to test without one.
Expand Down
30 changes: 15 additions & 15 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,51 +89,51 @@ distribution_archives {
}

windowsZip {
archiveClassifier = 'windows-x86_64'
archiveClassifier = 'windows-x64'
content {
archiveFiles(modulesFiles('windows-x86_64'), 'zip', 'windows', 'x64', true)
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', true)
}
}

noJdkWindowsZip {
archiveClassifier = 'no-jdk-windows-x86_64'
archiveClassifier = 'no-jdk-windows-x64'
content {
archiveFiles(modulesFiles('windows-x86_64'), 'zip', 'windows', 'x64', false)
archiveFiles(modulesFiles('windows-x64'), 'zip', 'windows', 'x64', false)
}
}

darwinTar {
archiveClassifier = 'darwin-x86_64'
archiveClassifier = 'darwin-x64'
content {
archiveFiles(modulesFiles('darwin-x86_64'), 'tar', 'darwin', 'x64', true)
archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', true)
}
}

noJdkDarwinTar {
archiveClassifier = 'no-jdk-darwin-x86_64'
archiveClassifier = 'no-jdk-darwin-x64'
content {
archiveFiles(modulesFiles('darwin-x86_64'), 'tar', 'darwin', 'x64', false)
archiveFiles(modulesFiles('darwin-x64'), 'tar', 'darwin', 'x64', false)
}
}

linuxAarch64Tar {
archiveClassifier = 'linux-aarch64'
linuxArm64Tar {
archiveClassifier = 'linux-arm64'
content {
archiveFiles(modulesFiles('linux-aarch64'), 'tar', 'linux', 'aarch64', true)
archiveFiles(modulesFiles('linux-arm64'), 'tar', 'linux', 'arm64', true)
}
}

linuxTar {
archiveClassifier = 'linux-x86_64'
archiveClassifier = 'linux-x64'
content {
archiveFiles(modulesFiles('linux-x86_64'), 'tar', 'linux', 'x64', true)
archiveFiles(modulesFiles('linux-x64'), 'tar', 'linux', 'x64', true)
}
}

noJdkLinuxTar {
archiveClassifier = 'no-jdk-linux-x86_64'
archiveClassifier = 'no-jdk-linux-x64'
content {
archiveFiles(modulesFiles('linux-x86_64'), 'tar', 'linux', 'x64', false)
archiveFiles(modulesFiles('linux-x64'), 'tar', 'linux', 'x64', false)
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
modulesFiles = { platform ->
copySpec {
eachFile {
if (it.relativePath.segments[-2] == 'bin' || (platform == 'darwin-x86_64' && it.relativePath.segments[-2] == 'MacOS')) {
if (it.relativePath.segments[-2] == 'bin' || (platform == 'darwin-x64' && it.relativePath.segments[-2] == 'MacOS')) {
// bin files, wherever they are within modules (eg platform specific) should be executable
// and MacOS is an alternative to bin on macOS
it.mode = 0755
Expand All @@ -321,7 +321,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}
def buildModules = buildModulesTaskProvider
List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64']
List excludePlatforms = ['linux-x64', 'linux-arm64', 'windows-x64', 'darwin-x64']
if (platform != null) {
excludePlatforms.remove(excludePlatforms.indexOf(platform))
} else {
Expand Down Expand Up @@ -408,6 +408,12 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {

jdkFiles = { Project project, String platform, String architecture ->
return copySpec {
/*
* Jdk uses aarch64 from ARM. Translating from arm64 to aarch64 which Jdk understands.
*/
if ("arm64".equals(architecture)) {
architecture = "aarch64"
}
from project.jdks."bundled_${platform}_${architecture}"
exclude "demo/**"
/*
Expand Down Expand Up @@ -585,11 +591,11 @@ subprojects {

['archives:windows-zip',
'archives:darwin-tar',
'archives:linux-aarch64-tar',
'archives:linux-arm64-tar',
'archives:linux-tar',
'archives:integ-test-zip',
'packages:rpm', 'packages:deb',
'packages:aarch64-rpm', 'packages:aarch64-deb'
'packages:arm64-rpm', 'packages:arm64-deb'
].forEach { subName ->
Project subproject = project("${project.path}:${subName}")
Configuration configuration = configurations.create(subproject.name)
Expand Down
24 changes: 12 additions & 12 deletions distribution/docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ apply plugin: 'opensearch.rest-resources'
testFixtures.useFixture()

configurations {
aarch64DockerSource
arm64DockerSource
dockerSource
}

dependencies {
aarch64DockerSource project(path: ":distribution:archives:linux-aarch64-tar", configuration:"default")
arm64DockerSource project(path: ":distribution:archives:linux-arm64-tar", configuration:"default")
dockerSource project(path: ":distribution:archives:linux-tar", configuration:"default")
}

ext.expansions = { Architecture architecture, DockerBase base, boolean local ->
String classifier
if (local) {
if (architecture == Architecture.AARCH64) {
classifier = "linux-aarch64"
if (architecture == Architecture.ARM64) {
classifier = "linux-arm64"
} else if (architecture == Architecture.X64) {
classifier = "linux-x86_64"
classifier = "linux-x64"
} else {
throw new IllegalArgumentException("Unsupported architecture [" + architecture + "]")
}
Expand Down Expand Up @@ -82,13 +82,13 @@ RUN curl --retry 8 -S -L \\

private static String buildPath(Architecture architecture, DockerBase base) {
return 'build/' +
(architecture == Architecture.AARCH64 ? 'aarch64-' : '') +
(architecture == Architecture.ARM64 ? 'arm64-' : '') +
'docker'
}

private static String taskName(String prefix, Architecture architecture, DockerBase base, String suffix) {
return prefix +
(architecture == Architecture.AARCH64 ? 'Aarch64' : '') +
(architecture == Architecture.ARM64 ? 'Arm64' : '') +
suffix
}

Expand Down Expand Up @@ -123,8 +123,8 @@ void addCopyDockerContextTask(Architecture architecture, DockerBase base) {

with dockerBuildContext(architecture, base, true)

if (architecture == Architecture.AARCH64) {
from configurations.aarch64DockerSource
if (architecture == Architecture.ARM64) {
from configurations.arm64DockerSource
} else {
from configurations.dockerSource
}
Expand All @@ -142,7 +142,7 @@ def createAndSetWritable(Object... locations) {

opensearch_distributions {
Architecture.values().each { eachArchitecture ->
"docker${ eachArchitecture == Architecture.AARCH64 ? '_aarch64' : '' }" {
"docker${ eachArchitecture == Architecture.ARM64 ? '_arm64' : '' }" {
architecture = eachArchitecture
type = 'docker'
version = VersionProperties.getOpenSearch()
Expand Down Expand Up @@ -225,10 +225,10 @@ subprojects { Project subProject ->
if (subProject.name.endsWith('-export')) {
apply plugin: 'distribution'

final Architecture architecture = subProject.name.contains('aarch64-') ? Architecture.AARCH64 : Architecture.X64
final Architecture architecture = subProject.name.contains('arm64-') ? Architecture.ARM64 : Architecture.X64
final DockerBase base = DockerBase.CENTOS

final String arch = architecture == Architecture.AARCH64 ? '-aarch64' : ''
final String arch = architecture == Architecture.ARM64 ? '-arm64' : ''
final String extension = 'docker.tar'
final String artifactName = "opensearch${arch}_test"

Expand Down
Loading

0 comments on commit 0e9f74e

Please sign in to comment.