You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ac...@apache.org on 2026/05/05 18:48:34 UTC
(kudu) branch master updated: [build] Include OS version in kudu-binary artifact names
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 54bc0b0cb [build] Include OS version in kudu-binary artifact names
54bc0b0cb is described below
commit 54bc0b0cb7454006e6380e476f063224cfe77156
Author: Abhishek Chennaka <ac...@cloudera.com>
AuthorDate: Thu Jan 29 20:43:12 2026 -0800
[build] Include OS version in kudu-binary artifact names
Update the naming convention for published Kudu mini-cluster binary
artifacts. Including the specific OS distribution and major version
prevents different build environments (e.g., RHEL 8 vs. RHEL 9) from
overwriting each other in the repository.
Update the logic in KuduBinaryJarExtractor.java and the tests
accordingly. Took the liberty of updating the Kudu version in
the test resources of kudu-test-utils.
Before:
kudu-binary-1.19.0-SNAPSHOT-osx-x86_64.jar
kudu-binary-1.19.0-SNAPSHOT-linux-x86_64.jar
After:
kudu-binary-1.19.0-SNAPSHOT-osx15-x86_64.jar
kudu-binary-1.19.0-SNAPSHOT-rhel9-x86_64.jar
Change-Id: I7f17971704dfec32a0256383bbc3029743b4674f
Reviewed-on: http://gerrit.cloudera.org:8080/23921
Reviewed-by: Alexey Serbin <al...@apache.org>
Tested-by: Abhishek Chennaka <ac...@cloudera.com>
---
.../mini-cluster/build_mini_cluster_binaries.sh | 24 +++++++------
.../relocate_binaries_for_mini_cluster.py | 39 ++++++++++++++++++----
examples/java/java-example/pom.xml | 1 +
java/kudu-test-utils/build.gradle | 6 +++-
.../kudu/test/cluster/KuduBinaryJarExtractor.java | 22 ++++++++++--
.../test/cluster/TestKuduBinaryJarExtractor.java | 34 ++++++++++++++-----
.../bin/kudu-tserver | 0
7 files changed, 99 insertions(+), 27 deletions(-)
diff --git a/build-support/mini-cluster/build_mini_cluster_binaries.sh b/build-support/mini-cluster/build_mini_cluster_binaries.sh
index 5914f8bae..31ff911f8 100755
--- a/build-support/mini-cluster/build_mini_cluster_binaries.sh
+++ b/build-support/mini-cluster/build_mini_cluster_binaries.sh
@@ -47,10 +47,8 @@
# specific release version.
# * artifact.prefix: The directory name at the root of the JAR under which the
# binary files can be found (similar to ./configure --prefix in autoconf).
-# * artifact.os: The operating system name using the same convention as
-# https://github.com/trustin/os-maven-plugin for ${os.detected.name}.
-# Practically speaking for Kudu at the time of writing, that is either
-# 'linux' or 'osx'.
+# * artifact.os: The operating system name and major version.
+# Examples: 'rhel9', 'ubuntu22', 'osx15'.
# * artifact.arch: The target system architecture using the same convention as
# os-maven-plugin for ${os.detected.arch}. Practically speaking for Kudu, at
# the time of writing this will always be set to x86_64.
@@ -59,9 +57,9 @@
#
# $ cat META-INF/apache-kudu-test-binary.properties
# format.version=1
-# artifact.version=1.8.0
-# artifact.prefix=kudu-binary-1.8.0-linux-x86_64
-# artifact.os=linux
+# artifact.version=1.19.0
+# artifact.prefix=kudu-binary-1.19.0-rhel9-x86_64
+# artifact.os=rhel9
# artifact.arch=x86_64
#
################################################################################
@@ -161,9 +159,15 @@ PROP_DIR="META-INF"
PROP_FILE="$PROP_DIR/apache-kudu-test-binary.properties"
FORMAT_VERSION=1
ARTIFACT_VERSION=$(cat $SOURCE_ROOT/version.txt)
-ARTIFACT_OS="linux"
-if [ $MACOS ]; then
- ARTIFACT_OS="osx"
+if [ "$MACOS" ]; then
+ MAJOR_VERSION=$(sw_vers -productVersion | cut -d. -f1)
+ ARTIFACT_OS="osx${MAJOR_VERSION}"
+elif [ -f /etc/os-release ]; then
+ . /etc/os-release
+ MAJOR_VERSION=$(echo $VERSION_ID | cut -d. -f1)
+ ARTIFACT_OS="${ID}${MAJOR_VERSION}"
+else
+ ARTIFACT_OS="linux"
fi
ARTIFACT_ARCH=$(uname -m)
rm -rf $PROP_DIR
diff --git a/build-support/mini-cluster/relocate_binaries_for_mini_cluster.py b/build-support/mini-cluster/relocate_binaries_for_mini_cluster.py
index c184e7713..254600811 100755
--- a/build-support/mini-cluster/relocate_binaries_for_mini_cluster.py
+++ b/build-support/mini-cluster/relocate_binaries_for_mini_cluster.py
@@ -30,6 +30,7 @@ import logging
import optparse
import os
import os.path
+import platform
import re
import shutil
import subprocess
@@ -239,16 +240,42 @@ def get_resolved_dep_library_paths_macos(binary_path):
rpaths = parse_load_commands_macos(LC_RPATH, load_commands)
return resolve_library_paths_macos(lib_search_paths, rpaths)
+def get_os_identifier():
+ """
+ Returns a uniform OS identifier (e.g., 'rhel8', 'osx14') to prevent artifact name
+ collisions between different OS versions.
+ """
+ if IS_MACOS:
+ # Extracts major version from macOS (e.g., '14' from '14.2.1')
+ try:
+ mac_ver = platform.mac_ver()[0]
+ major_version = mac_ver.split('.')[0]
+ return "osx%s" % major_version
+ except Exception:
+ return "osx"
+
+ if IS_LINUX:
+ info = {}
+ try:
+ with open("/etc/os-release") as f:
+ for line in f:
+ if "=" in line:
+ k, v = line.rstrip().split("=", 1)
+ info[k] = v.strip('"')
+ # Map 'ID' and 'VERSION_ID' to a clean string like 'rhel8'
+ os_id = info.get("ID", "linux").lower()
+ version_full = info.get("VERSION_ID", "")
+ major_version = version_full.split('.')[0]
+ return "%s%s" % (os_id, major_version)
+ except Exception:
+ return "linux"
+ raise NotImplementedError("Unsupported platform")
+
def get_artifact_name():
"""
Create an archive with an appropriate name. Including version, OS, and architecture.
"""
- if IS_LINUX:
- os_str = "linux"
- elif IS_MACOS:
- os_str = "osx"
- else:
- raise NotImplementedError("Unsupported platform")
+ os_str = get_os_identifier()
arch = os.uname()[4]
with open(os.path.join(SOURCE_ROOT, "version.txt"), 'r') as version:
line = version.readline()
diff --git a/examples/java/java-example/pom.xml b/examples/java/java-example/pom.xml
index f93cad69b..4775bef03 100644
--- a/examples/java/java-example/pom.xml
+++ b/examples/java/java-example/pom.xml
@@ -105,6 +105,7 @@
<profiles>
<!-- Profile to include kudu-binary JAR for running tests with packaged mini-cluster binaries.
Activated by default. Disable with -DuseLocalKuduBin=true when using locally built Kudu. -->
+ <!-- TODO(achennaka): Update the below with the next Kudu release -->
<profile>
<id>kudu-binary</id>
<activation>
diff --git a/java/kudu-test-utils/build.gradle b/java/kudu-test-utils/build.gradle
index f57b98dc1..5b4b218a1 100644
--- a/java/kudu-test-utils/build.gradle
+++ b/java/kudu-test-utils/build.gradle
@@ -51,7 +51,11 @@ dependencies {
if (propertyExists("useBinJar")) {
apply plugin: "com.google.osdetector"
def jarVersion = propertyWithDefault("useBinJar", project.version)
- runtimeOnly "org.apache.kudu:kudu-binary:$jarVersion:${osdetector.classifier}"
+ def osPrefix = osdetector.os == 'linux' ? osdetector.release : osdetector.os
+ def fullVersion = osdetector.os == 'linux' ? osdetector.release.version : osdetector.version
+ def majorVersion = fullVersion.split('\\.')[0]
+ def customClassifier = "${osPrefix}${majorVersion}-${osdetector.arch}"
+ runtimeOnly "org.apache.kudu:kudu-binary:$jarVersion:$customClassifier"
}
// Needed for CapturingLogAppender. Optional otherwise.
diff --git a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
index e34ea6688..b3109edea 100644
--- a/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
+++ b/java/kudu-test-utils/src/main/java/org/apache/kudu/test/cluster/KuduBinaryJarExtractor.java
@@ -67,13 +67,31 @@ public class KuduBinaryJarExtractor {
}
private static Properties getBinaryProps() throws IOException {
+ String expectedOs;
+ String os = DETECTOR.getOs();
+
+ if ("linux".equals(os)) {
+ String fullVersion = (DETECTOR.getRelease() != null) ?
+ DETECTOR.getRelease().getVersion() : "0";
+ String majorVersion = fullVersion.split("\\.")[0];
+ expectedOs = DETECTOR.getRelease().getId() + majorVersion;
+
+ } else if ("osx".equals(os)) {
+ String fullVersion = System.getProperty("os.version");
+ String majorVersion = (fullVersion != null) ? fullVersion.split("\\.")[0] : "";
+ expectedOs = "osx" + majorVersion;
+
+ } else {
+ expectedOs = os;
+ }
+
Enumeration<URL> resources = getCurrentClassLoader().getResources(KUDU_TEST_BIN_PROPS_PATH);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
try {
Properties props = loadBinaryProps(url);
- if (DETECTOR.getOs().equals(props.getProperty("artifact.os")) &&
- DETECTOR.getArch().equals(props.getProperty("artifact.arch"))) {
+ if (expectedOs.equals(props.getProperty("artifact.os")) &&
+ DETECTOR.getArch().equals(props.getProperty("artifact.arch"))) {
return props;
}
} catch (IOException ex) {
diff --git a/java/kudu-test-utils/src/test/java/org/apache/kudu/test/cluster/TestKuduBinaryJarExtractor.java b/java/kudu-test-utils/src/test/java/org/apache/kudu/test/cluster/TestKuduBinaryJarExtractor.java
index ad56b87c2..9b78f6255 100644
--- a/java/kudu-test-utils/src/test/java/org/apache/kudu/test/cluster/TestKuduBinaryJarExtractor.java
+++ b/java/kudu-test-utils/src/test/java/org/apache/kudu/test/cluster/TestKuduBinaryJarExtractor.java
@@ -109,13 +109,28 @@ public class TestKuduBinaryJarExtractor {
private static void writeProperties(String os, OutputStream out) throws IOException {
Properties properties = new Properties();
properties.setProperty("format.version", "1");
- properties.setProperty("artifact.version", "1.9.0-SNAPSHOT");
- properties.setProperty("artifact.prefix", "apache-kudu-1.9.0-SNAPSHOT");
+ properties.setProperty("artifact.version", "1.19.0-SNAPSHOT");
+ properties.setProperty("artifact.prefix", "apache-kudu-1.19.0-SNAPSHOT");
properties.setProperty("artifact.os", os);
properties.setProperty("artifact.arch", DETECTOR.getArch());
properties.store(out, "test");
}
+ private String getCurrentOsString() {
+ String majorVersion;
+ String id;
+ if ("linux".equals(DETECTOR.getOs())) {
+ id = DETECTOR.getRelease().getId();
+ majorVersion = DETECTOR.getRelease().getVersion().split("\\.")[0];
+ } else if ("osx".equals(DETECTOR.getOs())) {
+ id = "osx";
+ majorVersion = System.getProperty("os.version").split("\\.")[0];
+ } else {
+ return DETECTOR.getOs();
+ }
+ return id + majorVersion;
+ }
+
/**
* Create a ClassLoader. The parent of the ClassLoader will be the current thread context
* ClassLoader, if not set, or the ClassLoader that loaded this test class if not.
@@ -132,12 +147,12 @@ public class TestKuduBinaryJarExtractor {
@Test
public void testExtractJar() throws IOException, URISyntaxException {
- URI binaryJar = createKuduBinaryJar("osx").toUri();
+ URI binaryJar = createKuduBinaryJar(getCurrentOsString()).toUri();
binaryJar = URI.create("jar:" + binaryJar.toString());
Path extractedDir = KuduBinaryJarExtractor.extractJar(binaryJar,
- "apache-kudu-1.9.0-SNAPSHOT",
- Files.createTempDirectory("kudu-test"));
+ "apache-kudu-1.19.0-SNAPSHOT",
+ Files.createTempDirectory("kudu-test"));
Path extractedBinDir = Paths.get(extractedDir.toString(), "bin");
assertTrue(extractedBinDir.toFile().exists());
@@ -150,14 +165,17 @@ public class TestKuduBinaryJarExtractor {
KuduBinaryJarExtractor extractor = new KuduBinaryJarExtractor();
assertFalse(extractor.isKuduBinaryJarOnClasspath());
- boolean isOsX = System.getProperty("os.name").replaceAll("\\s", "").equalsIgnoreCase("macosx");
+ String currentOs = getCurrentOsString();
+ String wrongOs = currentOs.startsWith("osx") ? "rhel9" : "osx15";
- Path binaryJar = createKuduBinaryJar(isOsX ? "linux" : "osx");
+ Path binaryJar = createKuduBinaryJar(wrongOs);
+ // Negative test: Use a JAR with the wrong OS version/distro
ClassLoader childLoader = createChildClassLoader(new URL[] { binaryJar.toUri().toURL() });
Thread.currentThread().setContextClassLoader(childLoader);
assertFalse(extractor.isKuduBinaryJarOnClasspath());
- binaryJar = createKuduBinaryJar(!isOsX ? "linux" : "osx");
+ binaryJar = createKuduBinaryJar(currentOs);
+ // Positive test: Use a JAR with the matching OS version/distro
childLoader = createChildClassLoader(new URL[] { binaryJar.toUri().toURL() });
Thread.currentThread().setContextClassLoader(childLoader);
assertTrue(extractor.isKuduBinaryJarOnClasspath());
diff --git a/java/kudu-test-utils/src/test/resources/fake-kudu-binary/apache-kudu-1.9.0-SNAPSHOT/bin/kudu-tserver b/java/kudu-test-utils/src/test/resources/fake-kudu-binary/apache-kudu-1.19.0-SNAPSHOT/bin/kudu-tserver
similarity index 100%
rename from java/kudu-test-utils/src/test/resources/fake-kudu-binary/apache-kudu-1.9.0-SNAPSHOT/bin/kudu-tserver
rename to java/kudu-test-utils/src/test/resources/fake-kudu-binary/apache-kudu-1.19.0-SNAPSHOT/bin/kudu-tserver