Skip to content

Commit bbf05de

Browse files
chore: merge dependson and test for rofs volume mounts
1 parent 2545a82 commit bbf05de

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

modules/ecs_fargate/datadog.tf

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,6 @@ locals {
256256
}
257257
] : []
258258

259-
rofs_agent_depends_on = var.dd_readonly_root_filesystem ? [
260-
{
261-
condition = "SUCCESS"
262-
containerName = "init-volume"
263-
}
264-
] : []
265-
266259
# Volume configuration for task
267260
apm_dsd_volume = local.is_apm_dsd_volume ? [
268261
{
@@ -353,6 +346,16 @@ locals {
353346
local.dd_environment,
354347
)
355348

349+
dd_agent_dependency = concat(
350+
var.dd_readonly_root_filesystem ? [
351+
{
352+
condition = "SUCCESS"
353+
containerName = "init-volume"
354+
}
355+
] : [],
356+
try(var.dd_log_collection.fluentbit_config.is_log_router_dependency_enabled, false) && local.dd_firelens_log_configuration != null ? local.log_router_dependency : [],
357+
)
358+
356359
# Datadog Agent container definition
357360
dd_agent_container = concat(
358361
var.dd_readonly_root_filesystem ? [
@@ -404,11 +407,9 @@ locals {
404407
}
405408
],
406409

407-
dependsOn = local.rofs_agent_depends_on,
408-
409410
mountPoints = local.dd_agent_mount,
410411
logConfiguration = local.dd_firelens_log_configuration,
411-
dependsOn = try(var.dd_log_collection.fluentbit_config.is_log_router_dependency_enabled, false) && local.dd_firelens_log_configuration != null ? local.log_router_dependency : [],
412+
dependsOn = local.dd_agent_dependency
412413
systemControls = []
413414
volumesFrom = []
414415
},

smoke_tests/ecs_fargate/logging-only.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module "dd_task_logging_only" {
1515
dd_service = var.dd_service
1616
dd_essential = true
1717

18+
dd_readonly_root_filesystem = false
19+
1820
dd_dogstatsd = {
1921
enabled = false,
2022
}

tests/all_dd_inputs_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ func (s *ECSFargateSuite) TestAllDDInputs() {
2727
s.NoError(err, "Failed to parse container definitions")
2828
s.Equal(7, len(containers), "Expected 6 containers in the task definition")
2929

30+
initContainer, found := GetContainer(containers, "init-volume")
31+
s.True(found, "Container init-volume not found in definitions")
32+
AssertMountPoint(s.T(), initContainer, MountInitVolume)
33+
3034
// Test Agent Container
3135
agentContainer, found := GetContainer(containers, "datadog-agent")
3236
s.True(found, "Container datadog-agent not found in definitions")
@@ -37,6 +41,9 @@ func (s *ECSFargateSuite) TestAllDDInputs() {
3741
AssertPortMapping(s.T(), agentContainer, PortUDP)
3842
AssertPortMapping(s.T(), agentContainer, PortTCP)
3943
AssertMountPoint(s.T(), agentContainer, MountDdSocket)
44+
AssertMountPoint(s.T(), agentContainer, MountAgentConfig)
45+
AssertMountPoint(s.T(), agentContainer, MountAgentTmp)
46+
AssertMountPoint(s.T(), agentContainer, MountAgentRun)
4047
AssertContainerDependency(s.T(), agentContainer, DependencyLogRouter)
4148

4249
expectedAgentEnvvars := map[string]string{

tests/logging_only_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (s *ECSFargateSuite) TestLoggingOnly() {
2626

2727
err := json.Unmarshal([]byte(task["container_definitions"]), &containers)
2828
s.NoError(err, "Failed to parse container definitions")
29-
s.Equal(3, len(containers), "Expected 2 containers in the task definition")
29+
s.Equal(2, len(containers), "Expected 2 containers in the task definition")
3030

3131
// Test Agent Container
3232
agentContainer, found := GetContainer(containers, "datadog-agent")
@@ -73,7 +73,7 @@ func (s *ECSFargateSuite) TestLoggingOnly() {
7373
s.Equal("datadog-log-router", *agentContainer.DependsOn[0].ContainerName, "Agent should depend on datadog-log-router")
7474
s.Equal(types.ContainerConditionHealthy, agentContainer.DependsOn[0].Condition, "Agent should depend on log router being healthy")
7575

76-
s.Equal(3, len(agentContainer.MountPoints), "Expected 3 mount points for datadog-agent")
76+
s.Equal(0, len(agentContainer.MountPoints), "Expected 2 mount points for datadog-agent")
7777

7878
// Test Log Router Container
7979
logRouterContainer, found := GetContainer(containers, "datadog-log-router")

tests/utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import (
1616
var (
1717
MountDdSocket = types.MountPoint{SourceVolume: aws.String("dd-sockets"), ContainerPath: aws.String("/var/run/datadog"), ReadOnly: aws.Bool(false)}
1818
MountCWS = types.MountPoint{SourceVolume: aws.String("cws-instrumentation-volume"), ContainerPath: aws.String("/cws-instrumentation-volume"), ReadOnly: aws.Bool(false)}
19+
MountInitVolume = types.MountPoint{SourceVolume: aws.String("agent-config"), ContainerPath: aws.String("/agent-config"), ReadOnly: aws.Bool(false)}
20+
MountAgentConfig = types.MountPoint{SourceVolume: aws.String("agent-config"), ContainerPath: aws.String("/etc/datadog-agent"), ReadOnly: aws.Bool(false)}
21+
MountAgentTmp = types.MountPoint{SourceVolume: aws.String("agent-tmp"), ContainerPath: aws.String("/tmp"), ReadOnly: aws.Bool(false)}
22+
MountAgentRun = types.MountPoint{SourceVolume: aws.String("agent-run"), ContainerPath: aws.String("/opt/datadog-agent/run"), ReadOnly: aws.Bool(false)}
1923
PortTCP = types.PortMapping{ContainerPort: aws.Int32(8126), HostPort: aws.Int32(8126), Protocol: types.TransportProtocolTcp}
2024
PortUDP = types.PortMapping{ContainerPort: aws.Int32(8125), HostPort: aws.Int32(8125), Protocol: types.TransportProtocolUdp}
2125
DependencyAgent = types.ContainerDependency{ContainerName: aws.String("datadog-agent"), Condition: types.ContainerConditionHealthy}

0 commit comments

Comments
 (0)