I am trying to install the GCP Profiler agent for my app which runs in GKE, following instructions here: https://cloud.google.com/profiler/docs/profiling-java
I can't get past this error. Can someone help?
Could not find agent library /opt/cprof/profiler_java_agent.so in absolute path, with error: Error relocating /opt/cprof/profiler_java_agent.so: __pthread_key_create: initial-exec TLS resolves to dynamic definition in /opt/cprof/profiler_java_agent.so
This is the Dockerfile
FROM openjdk:8-jdk-alpine
RUN apk update && apk add --no-cache gcompat
RUN apk update && apk add --no-cache libc6-compat
WORKDIR /app
# The application's jar file
ARG JAR_FILE=target/example-svc-*.jar
# Add the application's jar to the container
ADD ${JAR_FILE} example-svc.jar
EXPOSE 5050
RUN mkdir -p /opt/cprof && \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
| tar xzv -C /opt/cprof
ENTRYPOINT ["java", \
"-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=example-svc,-cprof_service_version=0.0.1-SNAPSHOT", \
"-jar", "/app/example-svc.jar"]
The problem appears to be the base version of the container image you are working from. Looking at your Dockerfile, you are starting from:
openjdk:8-jdk-alpine
Digging into the docs of this, we find:
The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.
(Reference: openjdk)
Now if we look at the Google docs found here, we find the following requirement defined:
Supported operating systems:
- Linux versions whose standard C library is implemented with glibc.
... and this appears to be a conflict. Please try with an alternate version of an openjdk image that is not based on alpine
.