Skip to content

[fix] AS-5322: Fix gcompat for alpine image stability - #809

Open
hshankar31 wants to merge 8 commits into
3.1_dsfrom
AS5322-fix-library-upgrades
Open

[fix] AS-5322: Fix gcompat for alpine image stability#809
hshankar31 wants to merge 8 commits into
3.1_dsfrom
AS5322-fix-library-upgrades

Conversation

@hshankar31

@hshankar31 hshankar31 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Replace glibc-package with gcompat for Alpine image stability

Motivation

The 3.1_ds Alpine image previously injected real glibc into the container via
apachepulsar/glibc-base:2.38 — a pattern that installs libc.so.6 and
ld-linux-x86-64.so.2 alongside Alpine's native musl libc. Running two libc
implementations in the same process is inherently unsafe: memory allocated by
one allocator and freed by the other causes heap corruption, manifesting as JVM
crashes in Netty native transport, Conscrypt/BoringSSL, and RocksDB under load.
This issue was identified and fixed in upstream
apache/pulsar#23762 and is
already absent from the 4.0_ds branch. This PR brings 3.1_ds into
alignment.

Changes

docker/pulsar/Dockerfile

  • Removes the glibc-package multi-stage build (FROM apachepulsar/glibc-base:2.38) and all associated COPY/apk add steps
  • Replaces it with gcompat — a musl-native shim that implements the glibc ABI on top of musl using a single allocator, eliminating the dual-libc conflict
  • Adds ENV LD_PRELOAD=/lib/libgcompat.so.0 so Netty/Conscrypt native libraries resolve glibc symbols correctly at runtime
  • Adds ENV ROCKSDB_MUSL_LIBC=true to enable RocksDB's musl code path
  • Upgrades the JVM stage from a manual APK-key fetch to FROM amazoncorretto:17-alpine3.21
  • Replaces the separate python-deps build stage with an inline pip3 install --only-binary grpcio,pulsar-client to avoid C-extension compilation against musl
  • Adds apk upgrade to pick up the latest security fixes at build time
  • Adds ENV PULSAR_PID_DIR=/pulsar/logs to fix PID file write permissions for uid 10000

docker/glibc-package/

  • Deleted entirely; no longer needed

docker/pulsar-all/Dockerfile

  • Adds KPL 1.0.4 Alpine binary via a PULSAR_IO_KINESIS_KPL_IMAGE build ARG and copies the kinesis_producer native executable with required musl-compatible runtime deps

docker/kinesis-producer-alpine/

  • New directory containing the Dockerfile, build script, and musl patch to build the KPL 1.0.4 native binary for Alpine

docker/pulsar/test_script.sh

  • New script with Alpine-specific stability checks: verifies gcompat presence, LD_PRELOAD, ROCKSDB_MUSL_LIBC, absence of glibc artifacts, Python gRPC stub loading, and JVM crash-free startup

Testing

Validated end-to-end on a single-node minikube cluster (podman driver): all
pods reached 1/1 Running, ZooKeeper, BookKeeper, broker admin API, and a full
produce/consume round-trip all passed.

@hshankar31 hshankar31 changed the title [fix][docker] Fix python client version update [fix][update] AS-5322: Fix python client version update Sep 3, 2026
@hshankar31 hshankar31 changed the title [fix][update] AS-5322: Fix python client version update [fix] AS-5322: Fix python client version update Sep 3, 2026
Remove the apachepulsar/glibc-package approach (dual-libc injection) which
causes JVM crashes due to conflicting allocators between glibc and musl.
Replace with gcompat (musl-native glibc ABI shim) + LD_PRELOAD, aligning
with upstream apache#23762 and the 4.0_ds branch.

Changes:
- docker/pulsar/Dockerfile:
  - Remove glibc-package stage (FROM apachepulsar/glibc-base:2.38)
  - Add gcompat, libgcc, libstdc++, libuuid, coreutils to apk install
  - Upgrade JVM stage to amazoncorretto:17-alpine3.21 (removes manual APK key)
  - Replace python-deps build stage with inline pip3 install
    (--only-binary grpcio,pulsar-client to avoid musl build issues)
  - Add ENV LD_PRELOAD=/lib/libgcompat.so.0
  - Add ENV ROCKSDB_MUSL_LIBC=true
  - Add ENV PULSAR_PID_DIR=/pulsar/logs
  - Add apk upgrade for latest CVE fixes

- docker/glibc-package/: deleted entirely (no longer needed)

- docker/pulsar-all/Dockerfile:
  - Add KPL 1.0.4 Alpine-compatible binary via PULSAR_IO_KINESIS_KPL_IMAGE ARG
  - Add PULSAR_IO_KINESIS_KPL_PATH env and runtime deps (libstdc++, libgcc)

- docker/kinesis-producer-alpine/: new directory
  - Dockerfile, build-alpine.sh, musl patch, README for KPL 1.0.4 on Alpine

- pulsar-io/kinesis-kpl-shaded/pom.xml: pin to 1.0.4

- docker/pulsar/test_script.sh: Alpine stability checks (gcompat, LD_PRELOAD,
  libgcc, ROCKSDB_MUSL_LIBC, Python gRPC stub loading, JVM crash detection)
@hshankar31 hshankar31 changed the title [fix] AS-5322: Fix python client version update [fix] AS-5322: Fix gcompat for alpine image stability Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant