Skip to content

Commit

Permalink
fix(docker): add workaround for JDK-8345296 on OSX with _JAVA_OPTIONS (
Browse files Browse the repository at this point in the history
…#1872)

* fix(docker): add workaround for JDK-8345296 on OSX with _JAVA_OPTIONS

Signed-off-by: Charlie Le <[email protected]>

* fix(docker): add macOS arm64 support for JDK-8345296 workaround

Signed-off-by: Charlie Le <[email protected]>

* set adFailure back to off

---------

Signed-off-by: Charlie Le <[email protected]>
Co-authored-by: Juliano Costa <[email protected]>
  • Loading branch information
CharlieTLe and julianocosta89 authored Jan 13, 2025
1 parent 1fdc947 commit 0c7c104
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_JAVA_OPTIONS=-XX:UseSVE=0
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY)

DOCKER_COMPOSE_CMD ?= docker compose
DOCKER_COMPOSE_ENV=--env-file .env --env-file .env.override
DOCKER_COMPOSE_BUILD_ARGS=

# Java Workaround for macOS 15.2+ and M4 chips (see https://bugs.openjdk.org/browse/JDK-8345296)
ifeq ($(shell uname -m),arm64)
ifeq ($(shell uname -s),Darwin)
DOCKER_COMPOSE_ENV+= --env-file .env.arm64
DOCKER_COMPOSE_BUILD_ARGS+= --build-arg=_JAVA_OPTIONS=-XX:UseSVE=0
endif
endif

# see https://github.com/open-telemetry/build-tools/releases for semconvgen updates
# Keep links in semantic_conventions/README.md and .vscode/settings.json in sync!
Expand Down Expand Up @@ -77,11 +86,11 @@ install-tools: $(MISSPELL)

.PHONY: build
build:
$(DOCKER_COMPOSE_CMD) build
$(DOCKER_COMPOSE_CMD) build $(DOCKER_COMPOSE_BUILD_ARGS)

.PHONY: build-and-push
build-and-push:
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build --push
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) --push

# Create multiplatform builder for buildx
.PHONY: create-multiplatform-builder
Expand Down Expand Up @@ -209,7 +218,7 @@ ifdef SERVICE
endif

ifdef service
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) stop $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) rm --force $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) create $(service)
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ services:
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_LOGS_EXPORTER=otlp
- OTEL_SERVICE_NAME=ad
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -654,6 +656,8 @@ services:
- OPENSEARCH_JAVA_OPTS=-Xms300m -Xmx300m
- DISABLE_INSTALL_DEMO_CONFIG=true
- DISABLE_SECURITY_PLUGIN=true
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS
ulimits:
memlock:
soft: -1
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ services:
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_LOGS_EXPORTER=otlp
- OTEL_SERVICE_NAME=ad
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -658,6 +660,8 @@ services:
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=kafka
- KAFKA_HEAP_OPTS=-Xmx400m -Xms400m
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS
healthcheck:
test: nc -z kafka 9092
start_period: 10s
Expand Down Expand Up @@ -798,6 +802,8 @@ services:
- OPENSEARCH_JAVA_OPTS=-Xms300m -Xmx300m
- DISABLE_INSTALL_DEMO_CONFIG=true
- DISABLE_SECURITY_PLUGIN=true
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS
ulimits:
memlock:
soft: -1
Expand Down
4 changes: 3 additions & 1 deletion src/ad/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


FROM --platform=${BUILDPLATFORM} eclipse-temurin:21-jdk AS builder

ARG _JAVA_OPTIONS
WORKDIR /usr/src/app/

COPY ./src/ad/gradlew* ./src/ad/settings.gradle* ./src/ad/build.gradle ./
Expand All @@ -23,6 +23,8 @@ RUN ./gradlew installDist -PprotoSourceDir=./proto
FROM eclipse-temurin:21-jre

ARG OTEL_JAVA_AGENT_VERSION
ARG _JAVA_OPTIONS

WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/ ./
Expand Down
2 changes: 1 addition & 1 deletion src/flagd/demo.flagd.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"on": true,
"off": false
},
"defaultVariant": "on"
"defaultVariant": "off"
},
"kafkaQueueProblems": {
"description": "Overloads Kafka queue while simultaneously introducing a consumer side delay leading to a lag spike",
Expand Down

0 comments on commit 0c7c104

Please sign in to comment.