"Profiler attach failed" error when attaching to a process in another container inside the same Kubernetes pod

Issue

You have at least two containers running inside the same K8s pod: one with the dotMemory command-line profiler and the other one with the process you want to profile, e.g., a .NET application. The process namespace is shared between the containers inside the pod using the shareProcessNamespace field in the manifest file, for example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: diagsample
  labels:
    name: diagsample
spec:
  replicas: 1
  selector:
    matchLabels:
      name: diagsample
  template:
    metadata:
      labels:
        name: diagsample
    spec:
      volumes:
        - name: tmp
          emptyDir: {}
      shareProcessNamespace: true
      containers:
        - name: toolbox
          image: diagnosticstools
          imagePullPolicy: Never
          stdin: true
          tty: true
          volumeMounts:
            - name: tmp
              mountPath: /tmp
        - name: myapplication
          image: mainapptoprofile
          imagePullPolicy: Never
          volumeMounts:
            - name: tmp
              mountPath: /tmp

 

 After you try to attach the profiler to the application with

dotmemory attach <PID> or dotmemory get-snaphot <PID> 

you receive the "Profiler attach failed (HRESULT: 0x8007007E)" error.

Possible cause

The profiled process doesn't have access to the profiler’s .dll files.

Solution

Before starting a profiling session, ensure the following requirements are met:

  • The dotMemory process has access to the profiled process.
    You can do this by providing the shareProcessNamespace parameter in the manifest file as shown above.
  • The dotMemory process has access to the ‘temp’ folder of the profiled process.
    You can do this by providing the volumeMounts parameter in the manifest file as shown above.
  • The profiled process has access to the profiler .dll files.
    You can do this by moving the dotMemory command line profiler files to a folder accessible from both containers and running dotmemory attach command from this folder. For example, this could be the /tmp folder for the manifest as shown above.

 

 

0 out of 0 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request