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

[DCA] Send RFC-1123 compliant host names for k8s events

Open juliogreff opened this issue 2 years ago • 0 comments

What does this PR do?

This matches the rest of the core agent, where the "official" hostname is normalized, and the raw, non-RFC-1123 compliant hostname is just an alias. Without this, Kubernetes events will not have host tags attached.

Motivation

This was brought up as a support case, where the customer has an EC2 cluster name with underscores, and it's not easy for them to fix that due to existing data like dashboards and monitors.

Describe how to test/QA your changes

This is annoying to test, since it requires a k8s cluster running in EC2, with a kubernetes.io/cluster/name_with_underscores applied to the instances. Ideally setting DD_CLUSTER_NAME would work, but an invalid one is completely ignored. You can instead build a custom image where DD_CLUSTER_NAME is not ignored here: https://github.com/DataDog/datadog-agent/blob/main/pkg/util/kubernetes/clustername/clustername.go#L84

In either case, deploy both the core agent with a custom DD_TAGS, and the cluster agent with k8s event collection enabled. Check that the events show up with a host where the underscores have been replaced by hiphens, and that DD_TAGS has been applied.

Reviewer's Checklist

  • [ ] If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • [ ] Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • [ ] A release note has been added or the changelog/no-changelog label has been applied.
  • [ ] Changed code has automated tests for its functionality.
  • [ ] Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • [ ] At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • [ ] If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • [ ] If applicable, the need-change/operator and need-change/helm labels have been applied.
  • [ ] If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • [ ] If applicable, the config template has been updated.

juliogreff avatar Aug 09 '22 14:08 juliogreff