Skip to content

Commit f67776a

Browse files
committed
Fix process E2E: cap_add support, no static config, extended discovery timeout
- ddev/docker.py: add cap_add metadata support so integrations can grant Linux capabilities to the agent container (needed for sys-probe-lite process scanning) - datadog_checks_dev/docker.py: get_e2e_process_discovery_metadata now sets DD_PROC_ROOT=/host/proc and requests CAP_SYS_PTRACE + CAP_DAC_READ_SEARCH - krakend/conftest.py: yield None instead of a static instance — a pre-existing manual config blocks process autodiscovery from running - krakend/test_e2e.py: raise discovery_timeout to 90s (the process discovery check cycles every ~60s)
1 parent 8d9b3a9 commit f67776a

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

datadog_checks_dev/datadog_checks/dev/docker.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,15 @@ def get_e2e_process_discovery_metadata(
275275
],
276276
'env_vars': {
277277
'DD_AUTOCONFIG_EXCLUDE_FEATURES': 'docker',
278+
# The agent container has /proc:/host/proc mounted by ddev. Without this,
279+
# the workloadmeta process-collector scans /proc (the container's own PID
280+
# namespace) instead of /host/proc, so host processes aren't visible.
281+
'DD_PROC_ROOT': '/host/proc',
278282
},
283+
# sys-probe-lite needs these capabilities to read /proc entries of other
284+
# processes for service discovery. Without them it falls back to scanning
285+
# only the agent's own PID namespace and finds no host processes.
286+
'cap_add': ['SYS_PTRACE', 'DAC_READ_SEARCH'],
279287
}
280288

281289

datadog_checks_dev/tests/test_docker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def test_get_e2e_process_discovery_metadata(tmp_path):
8989
],
9090
'env_vars': {
9191
'DD_AUTOCONFIG_EXCLUDE_FEATURES': 'docker',
92+
'DD_PROC_ROOT': '/host/proc',
9293
},
94+
'cap_add': ['SYS_PTRACE', 'DAC_READ_SEARCH'],
9395
}
9496

9597

ddev/src/ddev/e2e/agent/docker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ def start(self, *, agent_build: str | None, local_packages: dict[Path, str], env
275275
for key, value in sorted(env_vars.items()):
276276
command.extend(['-e', f'{key}={value}'])
277277

278+
for cap in self.metadata.get('cap_add', []):
279+
command.extend(['--cap-add', cap])
280+
278281
# The docker `--add-host` command will reliably create entries in the `/etc/hosts` file,
279282
# otherwise, edits to that file will be overwritten on container restarts
280283
for host, ip in self.metadata.get('custom_hosts', []):

krakend/tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ def run_docker_process_e2e(env_vars: dict[str, str], conditions: list[LazyFuncti
7373
conditions=conditions,
7474
):
7575
yield (
76-
{
77-
"instances": [{"openmetrics_endpoint": OPEN_METRICS_ENDPOINT}],
78-
},
76+
None, # No static config — process autodiscovery must find and configure the check.
7977
get_e2e_process_discovery_metadata(),
8078
)
8179

krakend/tests/test_e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_e2e_process_discovery(dd_agent_check_discovery, is_process_e2e):
6060
if not is_process_e2e:
6161
pytest.skip('process discovery test only runs in the e2e-process environment')
6262

63-
aggregator = dd_agent_check_discovery(check_rate=True)
63+
aggregator = dd_agent_check_discovery(check_rate=True, discovery_timeout=90)
6464

6565
metadata_metrics = get_metrics_from_metadata()
6666

0 commit comments

Comments
 (0)