datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[BUG] Many healthcheck processes remain when agent hangs

Open at-wat opened this issue 3 years ago • 3 comments

Agent Environment

reproduced at least on 7.34.0 and 7.43.1

Describe what happened: When datadog agent process hangs for some reason, many healthcheck processes (/bin/sh /probe.sh, /opt/datadog-agent/bin/agent/agent health) hang and consume memory.

Healthcheck process is spawned by docker according to https://github.com/DataDog/datadog-agent/blob/8f26aeee4fcf195a5375b41f75f039d7040f220e/Dockerfiles/agent/Dockerfile#L197-L198 As docker and docker-compose don't have feature to stop or restart unhealthy container, health check will be triggered infinitely.

Describe what you expected: /opt/datadog-agent/bin/agent/agent health timeouts and return error when the agent is not responding.

Steps to reproduce the issue:

  1. Start datadog agent, for example by docker-compose
    version: "2"
    services:
      datadog-agent:
        image: datadog/agent:latest
        environment:
          DD_API_KEY: "${DD_API_KEY}"
          DD_LOGS_ENABLED: "true"
        volumes:
          - /etc/machine-id:/etc/machine-id:ro
          - /var/run/docker.sock:/var/run/docker.sock:ro
    
  2. Find agent PID and pause agent process by
    # kill -SIGSTOP ${agent_pid}
    
  3. Wait for some time
  4. Check processes
    $ docker top ${agent_container_name}
    UID   PID  PPID   C  STIME  TTY  TIME      CMD       
    root  464  32109  0  10:36  ?    00:00:00  /bin/sh /probe.sh 
    root  469  464    0  10:36  ?    00:00:00  /opt/datadog-agent/bin/agent/agent health
    root  620  32109  0  10:36  ?    00:00:00  /bin/sh /probe.sh 
    root  625  620    0  10:36  ?    00:00:00  /opt/datadog-agent/bin/agent/agent health
    root  704  32109  0  10:37  ?    00:00:00  /bin/sh /probe.sh 
    root  709  704    0  10:37  ?    00:00:00  /opt/datadog-agent/bin/agent/agent health
    root  780  32109  0  10:38  ?    00:00:00  /bin/sh /probe.sh 
    root  787  780    0  10:38  ?    00:00:00  /opt/datadog-agent/bin/agent/agent health
    ...
    

Additional environment details (Operating System, Cloud provider, etc):

Note This happened on our IoT system and caused OOM. We've added a healthcheck result handling (restart agent container) after finding this, however it would be nice to be avoided by default.

at-wat avatar Mar 24 '23 02:03 at-wat

We see this on v7.23.1 as well.

emj-io avatar Mar 29 '23 00:03 emj-io

@at-wat Thank you for your report! We're now tracking this internally and will update this issue as we work on it. 🙇

sgnn7 avatar Mar 30 '23 19:03 sgnn7

Hi @at-wat,

This bug should be fixed now and will be available in version 7.46.0 of the Agent once it's released.

hush-hush avatar Apr 25 '23 15:04 hush-hush