Skip to content

Commit 6ee0a3b

Browse files
chore: remove ust tagging for agent container
1 parent 1419f73 commit 6ee0a3b

File tree

7 files changed

+14
-43
lines changed

7 files changed

+14
-43
lines changed

modules/ecs_fargate/datadog.tf

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ locals {
183183
),
184184
# Merge UST docker labels with any existing docker labels.
185185
dockerLabels = merge(
186-
local.ust_docker_labels,
187-
// Placing this after local.ust_docker_labels ensures user defined UST labels are not overwritten.
188186
lookup(container, "dockerLabels", {}),
187+
local.ust_docker_labels,
189188
),
190189
# Append new volume mounts to any existing mountPoints.
191190
mountPoints = concat(
@@ -306,15 +305,9 @@ locals {
306305
local.dynamic_env,
307306
local.origin_detection_vars,
308307
local.cws_vars,
309-
local.ust_env_vars,
310308
local.dd_environment,
311309
)
312310

313-
dd_agent_docker_labels = merge(
314-
local.ust_docker_labels,
315-
var.dd_docker_labels,
316-
)
317-
318311
# Datadog Agent container definition
319312
dd_agent_container = [
320313
merge(
@@ -323,7 +316,7 @@ locals {
323316
image = "${var.dd_registry}:${var.dd_image_version}"
324317
essential = var.dd_essential
325318
environment = local.dd_agent_env
326-
dockerLabels = local.dd_agent_docker_labels
319+
dockerLabels = var.dd_docker_labels
327320
cpu = var.dd_cpu
328321
memory = var.dd_memory_limit_mib
329322
secrets = var.dd_api_key_secret != null ? [
@@ -364,11 +357,6 @@ locals {
364357

365358
dd_log_environment = var.dd_log_collection.fluentbit_config.environment != null ? var.dd_log_collection.fluentbit_config.environment : []
366359

367-
dd_log_agent_env = concat(
368-
local.ust_env_vars,
369-
local.dd_log_environment
370-
)
371-
372360
# Datadog log router container definition
373361
dd_log_container = local.is_fluentbit_supported ? [
374362
merge(
@@ -390,8 +378,8 @@ locals {
390378
memory_limit_mib = var.dd_log_collection.fluentbit_config.memory_limit_mib
391379
user = "0"
392380
mountPoints = var.dd_log_collection.fluentbit_config.mountPoints
393-
environment = local.dd_log_agent_env
394-
dockerLabels = local.dd_agent_docker_labels
381+
environment = local.dd_log_environment
382+
dockerLabels = var.dd_docker_labels
395383
portMappings = []
396384
systemControls = []
397385
volumesFrom = []
@@ -422,7 +410,7 @@ locals {
422410
command = ["/cws-instrumentation", "setup", "--cws-volume-mount", "/cws-instrumentation-volume"]
423411
mountPoints = local.cws_mount
424412
environment = local.ust_env_vars
425-
dockerLabels = local.dd_agent_docker_labels
413+
dockerLabels = var.dd_docker_labels
426414
portMappings = []
427415
systemControls = []
428416
volumesFrom = []

smoke_tests/ecs_fargate/ust-docker-labels.tf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module "dd_task_ust_docker_labels" {
3131

3232
dd_docker_labels = {
3333
"com.datadoghq.tags.service" : "docker-agent-service",
34+
"com.datadoghq.tags.env": "agent-dev",
35+
"com.datadoghq.tags.version": "v1.2.3"
3436
}
3537

3638
# Configure Task Definition with multiple containers
@@ -41,15 +43,6 @@ module "dd_task_ust_docker_labels" {
4143
image = "nginx:latest",
4244
essential = true,
4345
},
44-
{
45-
name = "app-overwritten-ust",
46-
image = "nginx:latest",
47-
essential = false,
48-
dockerLabels = {
49-
"com.datadoghq.tags.service" : "overwritten_name",
50-
"custom.label" = "custom-value"
51-
}
52-
}
5346
])
5447

5548
requires_compatibilities = ["FARGATE"]

tests/all_dd_disabled_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func (s *ECSFargateSuite) TestAllDDDisabled() {
4242
expectedAgentEnvVars := map[string]string{
4343
"DD_API_KEY": "test-api-key",
4444
"DD_SITE": "datadoghq.com",
45-
"DD_SERVICE": "test-service",
4645
"DD_TAGS": "team:cont-p, owner:container-monitoring",
4746
"DD_DOGSTATSD_TAG_CARDINALITY": "orchestrator",
4847
"DD_ECS_TASK_COLLECTION_ENABLED": "true",

tests/all_dd_inputs_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func (s *ECSFargateSuite) TestAllDDInputs() {
5151
"DD_API_KEY": "test-api-key",
5252
"DD_SITE": "datadoghq.com",
5353
"ECS_FARGATE": "true",
54-
"DD_SERVICE": "test-service",
5554
"DD_RUNTIME_SECURITY_CONFIG_EBPFLESS_ENABLED": "true",
5655
"DD_INSTALL_INFO_TOOL": "terraform",
5756
// "DD_INSTALL_INFO_INSTALLER_VERSION": "0.0.0",
@@ -61,7 +60,6 @@ func (s *ECSFargateSuite) TestAllDDInputs() {
6160
expectedLogOptions := map[string]string{
6261
"apikey": "test-api-key",
6362
"provider": "ecs",
64-
"dd_service": "dd-test",
6563
"Host": "http-intake.logs.datadoghq.com",
6664
"TLS": "on",
6765
"dd_source": "dd-test",

tests/apm_dsd_tcp_udp_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func (s *ECSFargateSuite) TestApmDsdTcpUdp() {
4242
expectedAgentEnvVars := map[string]string{
4343
"DD_API_KEY": "test-api-key",
4444
"DD_SITE": "datadoghq.com",
45-
"DD_SERVICE": "test-service",
4645
"DD_TAGS": "team:cont-p, owner:container-monitoring",
4746
"DD_DOGSTATSD_TAG_CARDINALITY": "orchestrator",
4847
"DD_ECS_TASK_COLLECTION_ENABLED": "true",

tests/logging_only_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ func (s *ECSFargateSuite) TestLoggingOnly() {
4242
expectedAgentEnvVars := map[string]string{
4343
"DD_API_KEY": "test-api-key",
4444
"DD_SITE": "datadoghq.com",
45-
"DD_SERVICE": "test-service",
4645
"DD_DOGSTATSD_TAG_CARDINALITY": "orchestrator",
4746
"DD_ECS_TASK_COLLECTION_ENABLED": "true",
4847
"ECS_FARGATE": "true",
@@ -87,7 +86,6 @@ func (s *ECSFargateSuite) TestLoggingOnly() {
8786

8887
// Verify log router environment variables
8988
expectedLogRouterEnvVars := map[string]string{
90-
"DD_SERVICE": "test-service",
9189
"DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL": "true",
9290
}
9391
AssertEnvVars(s.T(), logRouterContainer, expectedLogRouterEnvVars)

tests/ust_docker_labels_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (s *ECSFargateSuite) TestUSTDockerLabels() {
2525

2626
err := json.Unmarshal([]byte(task["container_definitions"]), &containers)
2727
s.NoError(err, "Failed to parse container definitions")
28-
s.Equal(5, len(containers), "Expected 4 containers in the task definition (3 app containers + 1 agent)")
28+
s.Equal(4, len(containers), "Expected 4 containers in the task definition (1 app container + 3 agent sidecar)")
2929

3030
// Expected UST docker labels that should be present on all application containers
3131
expectedUSTLabels := map[string]string{
@@ -41,18 +41,14 @@ func (s *ECSFargateSuite) TestUSTDockerLabels() {
4141
// Expect UST docker labels to be present on all Datadog containers with
4242
// overwritten labels when UST docker labels are specified.
4343
datadogContainers := []string{"datadog-agent", "datadog-log-router", "cws-instrumentation-init"}
44-
expectedUSTLabels["com.datadoghq.tags.service"] = "docker-agent-service"
44+
expectedAgentUSTLabels := map[string]string{
45+
"com.datadoghq.tags.service": "docker-agent-service",
46+
"com.datadoghq.tags.env": "agent-dev",
47+
"com.datadoghq.tags.version": "v1.2.3",
48+
}
4549
for _, containerName := range datadogContainers {
4650
container, found := GetContainer(containers, containerName)
4751
s.True(found, "Container %s not found in definitions", containerName)
48-
AssertDockerLabels(s.T(), container, expectedUSTLabels)
52+
AssertDockerLabels(s.T(), container, expectedAgentUSTLabels)
4953
}
50-
51-
// Expect UST docker labels to be overwritten on application container if docker labels
52-
// are specified in the container definition.
53-
overwrittenLabels, found := GetContainer(containers, "app-overwritten-ust")
54-
s.True(found, "Container app-overwritten-ust not found in definitions")
55-
expectedUSTLabels["com.datadoghq.tags.service"] = "overwritten_name"
56-
AssertDockerLabels(s.T(), overwrittenLabels, expectedUSTLabels)
57-
5854
}

0 commit comments

Comments
 (0)