Chaos Mesh Injecting JVM Fault Errors

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: Chaos Mesh注入JVM故障报错

| username: TiDBer_VhAAiIAA

Chaos Mesh can conduct pod fault experiments, but injecting JVM faults reports an error.
Environment: OCP
Error message:
Failed to apply chaos: rpc error: code = Unknown desc = com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file /proc/1991978/root/tmp/.java_pid1: target process 1991978 doesn’t respond within 10500ms or HotSpot VM not loaded at jdk.attach/sun.tools.attach.VirtualMachineImpl.(VirtualMachineImpl.java:100) at jdk.attach/sun.tools.attach.AttachProviderImpl.attachVirtualMachine(AttachProviderImpl.java:58) at jdk.attach/com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:207) at org.chaos_mesh.agent_installer.Install.attach(Install.java:203) at org.chaos_mesh.agent_installer.Install.main(Install.java:47) : exit status 1

| username: YangKeao | Original post link

Hello, may I ask which version of Chaos Mesh you are using? Is the Java process the first process in the running container?

It looks very similar to the issue initially described in AttachNotSupportedException! JVM Chaos Injection failed. · Issue #3330 · chaos-mesh/chaos-mesh · GitHub, where JVMChaos only injects into the first process in the container. If it is not Java, this error will occur. This issue has been fixed in version 2.2, and the bugfix for version 2.1 was merged twenty days ago, but no new bugfix version has been released.

| username: TiDBer_VhAAiIAA | Original post link

Hello, thank you for your reply. I am using Chaos Mesh version 2.2.0.
It seems that OCP assigns a UID to each container (or pod, not sure) by default. The Chaos Mesh daemon service is started as the root user, which causes an inconsistency.
After I specified my Java application’s container to start as the root user, the previous error disappeared, but another error occurred:
Failed to apply chaos: rpc error: code = Unknown desc = com.sun.tools.attach.AgentLoadException: 102 com.sun.tools.attach.AgentLoadException: 100 at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:108) at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:119) at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:147) at jdk.attach/com.sun.tools.attach.VirtualMachine.loadAgent(VirtualMachine.java:538) at org.chaos_mesh.agent_installer.Install.injectAgent(Install.java:255) at org.chaos_mesh.agent_installer.Install.main(Install.java:48) : exit status 1

The container logs report the following error:

| username: TiDBer_VhAAiIAA | Original post link

Supplement: Enter the directory mentioned in the error report, and the following files are in the directory: