Skip to content

Commit e62a55c

Browse files
pantovadpranikum
authored andcommitted
add support for s390x architecture (opensearch-project#4001)
* add s390x support in systemcallfilter opensearch-project#4000 Signed-off-by: Andrija Pantovic <andrija.pantovic@phoenix-systems.ch> * add gradle cfg for s390x Signed-off-by: Andrija Pantovic <andrija.pantovic@gmail.com> * change assertion for architecture Signed-off-by: Andrija Pantovic <andrija.pantovic@gmail.com> * change assertion for architecture Signed-off-by: Andrija Pantovic <andrija.pantovic@gmail.com> * update changelog Signed-off-by: Andrija Pantovic <andrija.pantovic@gmail.com> Signed-off-by: Andrija Pantovic <andrija.pantovic@phoenix-systems.ch> Signed-off-by: Andrija Pantovic <andrija.pantovic@gmail.com>
1 parent 286d934 commit e62a55c

File tree

12 files changed

+88
-5
lines changed

12 files changed

+88
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
33

44
## [Unreleased]
55
### Added
6+
- Add support for s390x architecture ([#4001](https://github.com/opensearch-project/OpenSearch/pull/4001))
67
- Github workflow for changelog verification ([#4085](https://github.com/opensearch-project/OpenSearch/pull/4085))
78
- Point in time rest layer changes for create and delete PIT API ([#4064](https://github.com/opensearch-project/OpenSearch/pull/4064))
89
- Added @dreamer-89 as an Opensearch maintainer ([#4342](https://github.com/opensearch-project/OpenSearch/pull/4342))

buildSrc/src/main/java/org/opensearch/gradle/Architecture.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
public enum Architecture {
3636

3737
X64,
38-
ARM64;
38+
ARM64,
39+
S390X;
3940

4041
public static Architecture current() {
4142
final String architecture = System.getProperty("os.arch", "");
@@ -45,6 +46,8 @@ public static Architecture current() {
4546
return X64;
4647
case "aarch64":
4748
return ARM64;
49+
case "s390x":
50+
return S390X;
4851
default:
4952
throw new IllegalArgumentException("can not determine architecture from [" + architecture + "]");
5053
}

buildSrc/src/main/java/org/opensearch/gradle/DistributionDownloadPlugin.java

+3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ private String dependencyNotation(OpenSearchDistribution distribution) {
247247
case X64:
248248
classifier = ":" + distribution.getPlatform() + "-x64";
249249
break;
250+
case S390X:
251+
classifier = ":" + distribution.getPlatform() + "-s390x";
252+
break;
250253
default:
251254
throw new IllegalArgumentException("Unsupported architecture: " + distribution.getArchitecture());
252255
}

buildSrc/src/main/java/org/opensearch/gradle/Jdk.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
public class Jdk implements Buildable, Iterable<File> {
5050

51-
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64"));
51+
private static final List<String> ALLOWED_ARCHITECTURES = Collections.unmodifiableList(Arrays.asList("aarch64", "x64", "s390x"));
5252
private static final List<String> ALLOWED_VENDORS = Collections.unmodifiableList(Arrays.asList("adoptium", "adoptopenjdk", "openjdk"));
5353
private static final List<String> ALLOWED_PLATFORMS = Collections.unmodifiableList(
5454
Arrays.asList("darwin", "freebsd", "linux", "mac", "windows")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.gradle;
10+
11+
import org.opensearch.gradle.test.GradleUnitTestCase;
12+
13+
public class ArchitectureTests extends GradleUnitTestCase {
14+
15+
final String architecture = System.getProperty("os.arch", "");
16+
17+
public void testCurrentArchitecture() {
18+
assertEquals(Architecture.X64, currentArchitecture("amd64"));
19+
assertEquals(Architecture.X64, currentArchitecture("x86_64"));
20+
assertEquals(Architecture.ARM64, currentArchitecture("aarch64"));
21+
assertEquals(Architecture.S390X, currentArchitecture("s390x"));
22+
}
23+
24+
public void testInvalidCurrentArchitecture() {
25+
assertThrows("can not determine architecture from [", IllegalArgumentException.class, () -> currentArchitecture("fooBar64"));
26+
}
27+
28+
/**
29+
* Determines the return value of {@link Architecture#current()} based on a string representing a potential OS Architecture.
30+
*
31+
* @param osArchToTest An expected value of the {@code os.arch} system property on another architecture.
32+
* @return the value of the {@link Architecture} enum which would have resulted with the given value.
33+
* @throws IllegalArgumentException if the string is not mapped to a value of the {@link Architecture} enum.
34+
*/
35+
private Architecture currentArchitecture(String osArchToTest) throws IllegalArgumentException {
36+
// Test new architecture
37+
System.setProperty("os.arch", osArchToTest);
38+
try {
39+
return Architecture.current();
40+
} finally {
41+
// Restore actual architecture property value
42+
System.setProperty("os.arch", this.architecture);
43+
}
44+
}
45+
}

buildSrc/src/test/java/org/opensearch/gradle/JdkDownloadPluginTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testUnknownArchitecture() {
108108
"11.0.2+33",
109109
"linux",
110110
"unknown",
111-
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64]"
111+
"unknown architecture [unknown] for jdk [testjdk], must be one of [aarch64, x64, s390x]"
112112
);
113113
}
114114

distribution/archives/build.gradle

+7
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ distribution_archives {
151151
}
152152
}
153153

154+
linuxS390xTar {
155+
archiveClassifier = 'linux-s390x'
156+
content {
157+
archiveFiles(modulesFiles('linux-s390x'), 'tar', 'linux', 's390x', false)
158+
}
159+
}
160+
154161
windowsZip {
155162
archiveClassifier = 'windows-x64'
156163
content {

distribution/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
280280
// Setup all required JDKs
281281
project.jdks {
282282
['darwin', 'linux', 'windows'].each { platform ->
283-
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64'] : ['x64']).each { architecture ->
283+
(platform == 'linux' || platform == 'darwin' ? ['x64', 'aarch64', 's390x'] : ['x64']).each { architecture ->
284284
"bundled_${platform}_${architecture}" {
285285
it.platform = platform
286286
it.version = VersionProperties.getBundledJdk(platform)
@@ -353,7 +353,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
353353
}
354354
}
355355
def buildModules = buildModulesTaskProvider
356-
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'windows-x64', 'darwin-arm64']
356+
List excludePlatforms = ['darwin-x64', 'freebsd-x64', 'linux-x64', 'linux-arm64', 'linux-s390x', 'windows-x64', 'darwin-arm64']
357357
if (platform != null) {
358358
excludePlatforms.remove(excludePlatforms.indexOf(platform))
359359
} else {

distribution/docker/build.gradle

+8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ testFixtures.useFixture()
2727

2828
configurations {
2929
arm64DockerSource
30+
s390xDockerSource
3031
dockerSource
3132
}
3233

3334
dependencies {
3435
arm64DockerSource project(path: ":distribution:archives:linux-arm64-tar", configuration:"default")
36+
s390xDockerSource project(path: ":distribution:archives:linux-s390x-tar", configuration:"default")
3537
dockerSource project(path: ":distribution:archives:linux-tar", configuration:"default")
3638
}
3739

@@ -42,6 +44,8 @@ ext.expansions = { Architecture architecture, DockerBase base, boolean local ->
4244
classifier = "linux-arm64"
4345
} else if (architecture == Architecture.X64) {
4446
classifier = "linux-x64"
47+
} else if (architecture == Architecture.S390X) {
48+
classifier = "linux-s390x"
4549
} else {
4650
throw new IllegalArgumentException("Unsupported architecture [" + architecture + "]")
4751
}
@@ -85,12 +89,14 @@ RUN curl --retry 8 -S -L \\
8589
private static String buildPath(Architecture architecture, DockerBase base) {
8690
return 'build/' +
8791
(architecture == Architecture.ARM64 ? 'arm64-' : '') +
92+
(architecture == Architecture.S390X ? 's390x-' : '') +
8893
'docker'
8994
}
9095

9196
private static String taskName(String prefix, Architecture architecture, DockerBase base, String suffix) {
9297
return prefix +
9398
(architecture == Architecture.ARM64 ? 'Arm64' : '') +
99+
(architecture == Architecture.S390X ? 'S390x' : '') +
94100
suffix
95101
}
96102

@@ -127,6 +133,8 @@ void addCopyDockerContextTask(Architecture architecture, DockerBase base) {
127133

128134
if (architecture == Architecture.ARM64) {
129135
from configurations.arm64DockerSource
136+
} else if (architecture == Architecture.S390X) {
137+
from configurations.s390xDockerSource
130138
} else {
131139
from configurations.dockerSource
132140
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*
8+
* Modifications Copyright OpenSearch Contributors. See
9+
* GitHub history for details.
10+
*/
11+
12+
// This file is intentionally blank. All configuration of the
13+
// export is done in the parent project.

server/src/main/java/org/opensearch/bootstrap/SystemCallFilter.java

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static class Arch {
259259
Map<String, Arch> m = new HashMap<>();
260260
m.put("amd64", new Arch(0xC000003E, 0x3FFFFFFF, 57, 58, 59, 322, 317));
261261
m.put("aarch64", new Arch(0xC00000B7, 0xFFFFFFFF, 1079, 1071, 221, 281, 277));
262+
m.put("s390x", new Arch(0x80000016, 0xFFFFFFFF, 2, 190, 11, 354, 348));
262263
ARCHITECTURES = Collections.unmodifiableMap(m);
263264
}
264265

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ List projects = [
4747
'distribution:archives:freebsd-tar',
4848
'distribution:archives:no-jdk-freebsd-tar',
4949
'distribution:archives:linux-arm64-tar',
50+
'distribution:archives:linux-s390x-tar',
5051
'distribution:archives:linux-tar',
5152
'distribution:archives:no-jdk-linux-tar',
5253
'distribution:docker',
5354
'distribution:docker:docker-arm64-build-context',
5455
'distribution:docker:docker-arm64-export',
56+
'distribution:docker:docker-s390x-export',
5557
'distribution:docker:docker-build-context',
5658
'distribution:docker:docker-export',
5759
'distribution:packages:arm64-deb',

0 commit comments

Comments
 (0)