Datadog-agent: Datadog Agent tries to fetch hostname from GCE when provider is AWS.

Created on 26 May 2019  路  2Comments  路  Source: DataDog/datadog-agent

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

Getting the status from the agent.

===============
Agent (v6.11.2)
===============

  Status date: 2019-05-26 12:35:53.919502 UTC
  Agent start: 2019-05-24 05:17:30.025123 UTC
  Pid: 337
  Python Version: 2.7.16
  Check Runners: 4
  Log Level: info

  Paths
  =====
    Config File: /etc/datadog-agent/datadog.yaml
    conf.d: /etc/datadog-agent/conf.d
    checks.d: /etc/datadog-agent/checks.d

  Clocks
  ======
    NTP offset: -748碌s
    System UTC time: 2019-05-26 12:35:53.919502 UTC

  Host Info
  =========
    bootTime: 2019-05-03 05:51:42.000000 UTC
    kernelVersion: 4.9.0-7-amd64
    os: linux
    platform: debian
    platformFamily: debian
    platformVersion: buster/sid
    procs: 64
    uptime: 503h25m56s

  Hostnames
  =========
    ec2-hostname: <REDACTED>.eu-west-1.compute.internal
    host_aliases: [<REDACTED>.k8s.local]
    hostname: i-<REDACTED>
    instance-id: i-<REDACTED>
    socket-fqdn: datadog-agent-6hzkg
    socket-hostname: datadog-agent-6hzkg
    hostname provider: aws
    unused hostname providers:
      configuration/environment: hostname is empty
      gce: unable to retrieve hostname from GCE: status code 404 trying to GET http://169.254.169.254/computeMetadata/v1/instance/hostname

Describe what happened:
Datadog-Agent tries to fetch hostname from GCE metadata endpoint while running on AWS.
gce: unable to retrieve hostname from GCE: status code 404 trying to GET http://169.254.169.254/computeMetadata/v1/instance/hostname

Describe what you expected:
Hostname would be fetched from ec2 metadata api as per: https://github.com/DataDog/datadog-agent/blob/e47ccf7147139efd36d6e05e3de63f776a32d2b1/pkg/util/ec2/ec2.go#L33

Steps to reproduce the issue:
-

Additional environment details (Operating System, Cloud provider, etc):
Datadog agent is deployed as a daemonset on kubernetes. Cluster is deployed using KOPS, running on AWS EC2 instances.

Most helpful comment

It does seem to be working as expected, but the rule of least astonishment might have been violated. Why should there be warning logs about GCE when the agent is deployed in a completely unrelated environment? I believe there is room for improvement here.

All 2 comments

Err. I read the code and it seems to be completely normal that it actually walks trough everything?
I assume this is working as expected then.

https://github.com/DataDog/datadog-agent/blob/98a6c25b581f381d80a90bb408d30dcf8620d015/pkg/util/hostname.go#L198

It does seem to be working as expected, but the rule of least astonishment might have been violated. Why should there be warning logs about GCE when the agent is deployed in a completely unrelated environment? I believe there is room for improvement here.

Was this page helpful?
0 / 5 - 0 ratings