1

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"]
Anoop Hallimala
  • 625
  • 1
  • 11
  • 25

1 Answers1

2

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.

Kolban
  • 13,794
  • 3
  • 38
  • 60
  • Thank you for pointing that out. *-alpine is supposed to be the smallest image. Can you suggest some alternatives? – Anoop Hallimala Dec 07 '19 at 12:50
  • 1
    If we look here ... https://hub.docker.com/_/openjdk ... we find that you can use a non-alpine version pulling from openjdk:8-jdk While it is indeed true that alpine is documented as being smaller, if it doesn't work for the task you have at hand then it is of no use to you. Rather than start out optimizing for performance and size, start out optimizing for functional correctness ... from there ... and only if needed, you can tune. – Kolban Dec 07 '19 at 16:10
  • Noted. Thank you for your help. – Anoop Hallimala Dec 08 '19 at 07:12