Skip to content

Commit

Permalink
Pin the Java toolchain to remotejdk_17 (buildfarm#1509)
Browse files Browse the repository at this point in the history
Closes buildfarm#1508

Cleanups:
- remove the unused `ubuntu-bionic` base image
- replace `ubuntu-jammy:jammy-java11-gcc` with `ubuntu-mantic:mantic-java17-gcc`
- replace `amazoncorretto:19` with `ubuntu-mantic:mantic-java17-gcc`
- swap inverted log file names in a file
  • Loading branch information
stefanobaghino authored Oct 24, 2023
1 parent 578589f commit dfa5937
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .bazelci/run_server_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ bazel build //src/main/java/build/buildfarm:buildfarm-shard-worker
bazel build //src/main/java/build/buildfarm:buildfarm-server

# Start a single worker
bazel run //src/main/java/build/buildfarm:buildfarm-shard-worker $(pwd)/examples/config.minimal.yml > server.log 2>&1 &
bazel run //src/main/java/build/buildfarm:buildfarm-shard-worker $(pwd)/examples/config.minimal.yml > worker.log 2>&1 &
echo "Started buildfarm-shard-worker..."

# Start a single server
bazel run //src/main/java/build/buildfarm:buildfarm-server $(pwd)/examples/config.minimal.yml > worker.log 2>&1 &
bazel run //src/main/java/build/buildfarm:buildfarm-server $(pwd)/examples/config.minimal.yml > server.log 2>&1 &
echo "Started buildfarm-server..."

echo "Wait for startup to finish..."
Expand Down
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
build --java_language_version=17
build --java_runtime_version=remotejdk_17

build --tool_java_language_version=17
build --tool_java_runtime_version=remotejdk_17

common --enable_platform_specific_config

build:fuse --define=fuse=true
Expand Down
6 changes: 3 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sh_binary(
java_image(
name = "buildfarm-server",
args = ["/app/build_buildfarm/examples/config.minimal.yml"],
base = "@amazon_corretto_java_image_base//image",
base = "@ubuntu-mantic//image",
classpath_resources = [
"//src/main/java/build/buildfarm:configs",
],
Expand Down Expand Up @@ -148,14 +148,14 @@ oss_audit(
# Download cgroup-tools so that the worker is able to restrict actions via control groups.
download_pkgs(
name = "worker_pkgs",
image_tar = "@ubuntu-jammy//image",
image_tar = "@ubuntu-mantic//image",
packages = ["cgroup-tools"],
tags = ["container"],
)

install_pkgs(
name = "worker_pkgs_image",
image_tar = "@ubuntu-jammy//image",
image_tar = "@ubuntu-mantic//image",
installables_tar = ":worker_pkgs.tar",
installation_cleanup_commands = "rm -rf /var/lib/apt/lists/*",
output_image_name = "worker_pkgs_image",
Expand Down
22 changes: 3 additions & 19 deletions images.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,9 @@ def buildfarm_images():
)

container_pull(
name = "ubuntu-bionic",
digest = "sha256:4bc527c7a288da405f2041928c63d0a6479a120ad63461c2f124c944def54be2",
name = "ubuntu-mantic",
digest = "sha256:1419bba15470a95242e917b3abcd8981ae36707b99df5ac705e1eee4d920c51c",
registry = "index.docker.io",
repository = "bazelbuild/buildfarm-worker-base",
tag = "bionic-java11-gcc",
)

container_pull(
name = "ubuntu-jammy",
digest = "sha256:da847ee259ebe7f00631a2f0146d9add60ff0f94b031a2e522ce94c78b1335c2",
registry = "index.docker.io",
repository = "bazelbuild/buildfarm-worker-base",
tag = "jammy-java11-gcc",
)

container_pull(
name = "amazon_corretto_java_image_base",
registry = "index.docker.io",
repository = "amazoncorretto",
tag = "19",
digest = "sha256:81d0df4412140416b27211c999e1f3c4565ae89a5cd92889475d20af422ba507",
tag = "mantic-java17-gcc",
)
10 changes: 8 additions & 2 deletions jvm_flags.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def ensure_accurate_metadata():
"//config:windows": ["-Dsun.nio.fs.ensureAccurateMetadata=true"],
})

def add_opens_sun_nio_fs():
return select({
"//conditions:default": [],
"//config:windows": ["--add-opens java.base/sun.nio.fs=ALL-UNNAMED"],
})

def server_telemetry():
return select({
"//config:open_telemetry": SERVER_TELEMETRY_JVM_FLAGS,
Expand All @@ -67,7 +73,7 @@ def worker_telemetry():
})

def server_jvm_flags():
return RECOMMENDED_JVM_FLAGS + DEFAULT_LOGGING_CONFIG + ensure_accurate_metadata() + server_telemetry()
return RECOMMENDED_JVM_FLAGS + DEFAULT_LOGGING_CONFIG + ensure_accurate_metadata() + add_opens_sun_nio_fs() + server_telemetry()

def worker_jvm_flags():
return RECOMMENDED_JVM_FLAGS + DEFAULT_LOGGING_CONFIG + ensure_accurate_metadata() + worker_telemetry()
return RECOMMENDED_JVM_FLAGS + DEFAULT_LOGGING_CONFIG + ensure_accurate_metadata() + add_opens_sun_nio_fs() + worker_telemetry()
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

public class JavaProcessWrapper extends ProcessWrapper {

// Get the path of the JVM from the current process to avoid breaking the Bazel sandbox
public static final String CURRENT_JVM_COMMAND =
ProcessHandle.current().info().command().orElseThrow(() -> new RuntimeException("Unable to retrieve the path of the running JVM"));

public JavaProcessWrapper(
Path workDir, String classPath, String fullClassName, String[] args
) throws IOException {
super(workDir, cmdArgs(
new String[]{
"java",
CURRENT_JVM_COMMAND,
"-cp",
classPath,
fullClassName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import persistent.bazel.client.PersistentWorker;
import persistent.bazel.client.WorkerKey;
import persistent.common.processes.JavaProcessWrapper;
import persistent.testutil.ProcessUtils;
import persistent.testutil.WorkerUtils;

Expand Down Expand Up @@ -55,7 +56,7 @@ public void endToEndAdder() throws Exception {
);

ImmutableList<String> initCmd = ImmutableList.of(
"java",
JavaProcessWrapper.CURRENT_JVM_COMMAND,
"-cp",
jarPath.toString(),
"adder.Adder",
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/build/buildfarm/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//:jvm_flags.bzl", "ensure_accurate_metadata")
load("//:jvm_flags.bzl", "add_opens_sun_nio_fs", "ensure_accurate_metadata")

package(
default_visibility = ["//src:__subpackages__"],
Expand All @@ -15,7 +15,7 @@ java_binary(
classpath_resources = [
":configs",
],
jvm_flags = ensure_accurate_metadata(),
jvm_flags = ensure_accurate_metadata() + add_opens_sun_nio_fs(),
main_class = "build.buildfarm.server.BuildFarmServer",
visibility = ["//visibility:public"],
runtime_deps = [
Expand All @@ -29,7 +29,7 @@ java_binary(
classpath_resources = [
":configs",
],
jvm_flags = ensure_accurate_metadata(),
jvm_flags = ensure_accurate_metadata() + add_opens_sun_nio_fs(),
main_class = "build.buildfarm.worker.shard.Worker",
visibility = ["//visibility:public"],
runtime_deps = [
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/build/buildfarm/cas/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("//:jvm_flags.bzl", "ensure_accurate_metadata")
load("//:jvm_flags.bzl", "add_opens_sun_nio_fs", "ensure_accurate_metadata")

java_test(
name = "tests",
size = "small",
srcs = glob(["**/*.java"]),
jvm_flags = ensure_accurate_metadata(),
jvm_flags = ensure_accurate_metadata() + add_opens_sun_nio_fs(),
test_class = "build.buildfarm.AllTests",
deps = [
"//src/main/java/build/buildfarm/cas",
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/build/buildfarm/common/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("//:jvm_flags.bzl", "ensure_accurate_metadata")
load("//:jvm_flags.bzl", "add_opens_sun_nio_fs", "ensure_accurate_metadata")

java_test(
name = "tests",
size = "small",
srcs = glob(["*.java"]),
jvm_flags = ensure_accurate_metadata(),
jvm_flags = ensure_accurate_metadata() + add_opens_sun_nio_fs(),
test_class = "build.buildfarm.AllTests",
deps = [
"//src/main/java/build/buildfarm/common",
Expand Down

0 comments on commit dfa5937

Please sign in to comment.