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

panic: runtime error when running Datadog Agent on ECS Fargate

Open moby04 opened this issue 4 years ago • 3 comments

Output of the info page (if this is a bug)

(Paste the output of the info page here)

Describe what happened:

I try to run Datadog Agent in ECS Fargate (platform version 1.4.0) in a service with sidecar that would build http_check configuration before starting container. It is a custom Python script that collects information about endpoints and generates basic yaml using this template:

init_config:

instances:
{% for name, url in endpoints.items() %}
    - name: {{ name }}
      url: {{ url }}
{% endfor %}

This is created on shared volume and mounted in Datadog Agent container under

mount_points = [
    {
      "containerPath" = "/etc/datadog-agent/conf.d/http_check.d"
      "sourceVolume" = "shared-config"
    }
  ]

Datadog is configured to start only after above mentioned script finishes generation of config (ECS depends_on feature).

Other env variables injected into container

DD_APM_ENABLED | false
DD_APM_ENV | prod
DD_APM_NON_LOCAL_TRAFFIC | true
DD_DOGSTATSD_NON_LOCAL_TRAFFIC | true
DD_DOGSTATSD_TAGS | env:prod
DD_LOGS_ENABLED | true
ECS_FARGATE | true

and secret DD_API_KEY as secret loaded from SSM.

I tried with the version latest at the time of writing this issue (7.32.4) and some older one just to test (7.29.0) in variants with and without -jmx suffix.

In each case I end up with panic error:

ecs-cli logs --task-id ${TASK} --container-name datadog_agent
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x128 pc=0xd11dc6]

goroutine 1 [running]:
github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs.getContainerLogConfig(0x0, 0x7ffd29b5d219, 0xd, 0xc000546400)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs/logs_app.go:281 +0x26
github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs.getLogConfiguration(0xc0005b2b40, 0x7ffd29b5d1e7, 0x20, 0x7ffd29b5d219, 0xd, 0x0, 0x0, 0x0)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs/logs_app.go:248 +0x12f
github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs.logsRequest(0xc0003c9e00, 0x1ab17e0, 0xc000528560, 0xc000234cc0, 0x0, 0x0, 0x203000, 0x203000, 0x203000)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs/logs_app.go:97 +0x142
github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs.Logs(0xc0003c9e00)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/modules/cli/logs/logs_app.go:66 +0x245
github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli.HandleAction(0x132c560, 0x17bcee8, 0xc0003c9e00, 0xc00034f800, 0x0)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli/app.go:487 +0x7c
github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli.Command.Run(0x171aef6, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1762a09, 0x8a, 0x0, ...)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli/command.go:207 +0x92a
github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli.(*App).Run(0xc0002d69c0, 0xc0000c0120, 0x6, 0x6, 0x0, 0x0)
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/vendor/github.com/urfave/cli/app.go:250 +0x794
main.main()
	/go/src/github.com/aws/amazon-ecs-cli/ecs-cli/main.go:94 +0x983

When I replicated this setup with docker-compose locally it worked fine.

Describe what you expected:

Datadog Agent should start sending http checks normally or at least return some readable debug information.

Steps to reproduce the issue:

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

AWS ECS Fargate platform version 1.4.0

moby04 avatar Jan 26 '22 09:01 moby04

It looks like the panic is in the ecs-cli tool, rather than an issue with the agent. Unless I've misunderstood something, perhaps upgrading ecs-cli to the latest version would help? If not, that would be a better place to report the issue. Please let me know if I've misunderstood the issue.

djmitche avatar Jan 31 '22 16:01 djmitche

Maybe I was not clear enough but the issue happens when I try to use datadog/agent image in a few versions. Indeed the stack trace suggests that the panic comes from ecs-cli tool but entire image is officially managed by Datadog (https://hub.docker.com/r/datadog/agent - verified publisher). I'd say that making sure that dependencies are in proper versions is a part of image preparation...

moby04 avatar Jan 31 '22 20:01 moby04

Through the support ticket, we discovered the container name is actually datadog-agent. However, in the ecs-cli command, it was inadvertently typed using datadog_agent (notice the _ instead of -). Hence, this is why ecs-cli panics as there is no container called datadog_agent.

git-thuerk-done avatar Apr 13 '22 16:04 git-thuerk-done