Skip to content

[base] Add get_agent_embedded_path helper#23644

Draft
Kyle-Neale wants to merge 1 commit intomasterfrom
kyle.neale/agent-embedded-path
Draft

[base] Add get_agent_embedded_path helper#23644
Kyle-Neale wants to merge 1 commit intomasterfrom
kyle.neale/agent-embedded-path

Conversation

@Kyle-Neale
Copy link
Copy Markdown
Contributor

Summary

  • Adds get_agent_embedded_path(*parts) to datadog_checks_base.utils.agent.common, which reads run_path from the agent config and joins it under embedded/....
  • Returns None when run_path is unset so callers can decide whether the miss is fatal or a fallback.
  • Works for both standard installs (/opt/datadog-agent/run) and Remote-Management installs (/opt/datadog-packages/datadog-agent/<version>/run).

Motivation

When the agent is installed with Remote Management enabled, hardcoded /opt/datadog-agent paths silently miss because the actual install lives under /opt/datadog-packages/datadog-agent/<version>/. PR #20574 fixed this inline for glusterfs. This PR extracts a shared helper in the base check so the same fix can be applied to every affected integration (glusterfs, kafka_consumer, kafka_actions, nfsstat) in follow-up commits on this branch.

Jira: AI-5681
Related: #20574

Test plan

  • ddev test -fs datadog_checks_base — clean
  • ddev --no-interactive test datadog_checks_base -- -k test_agent_common — 5/5 passing
  • Follow-up commits will migrate glusterfs, kafka_consumer, kafka_actions, nfsstat and add per-integration tests

🤖 Generated with Claude Code

Resolve paths under the agent's `embedded` directory by reading
`run_path` from the agent config instead of assuming the install
sits at `/opt/datadog-agent`. Works for both standard installs and
Remote-Management installs at `/opt/datadog-packages/datadog-agent/<ver>`.

Returns `None` when `run_path` is unset so callers can decide whether
the miss is fatal (raise) or skip a fallback.

Refs: AI-5681
Follow-up to #20574 which inlined this lookup in glusterfs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 8, 2026

Validation Report

All 20 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@datadog-prod-us1-4
Copy link
Copy Markdown
Contributor

datadog-prod-us1-4 Bot commented May 8, 2026

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 4 Tests failed

TestGetAgentEmbeddedPath::test_no_parts_returns_embedded_dir from test_agent_common.py   View in Datadog   (Fix with Cursor)
assert '/opt/datadog-agent\\embedded' == '/opt/datadog-agent/embedded'
  
  - /opt/datadog-agent/embedded
  ?                   ^
  + /opt/datadog-agent\embedded
  ?                   ^
TestGetAgentEmbeddedPath::test_remote_management_install from test_agent_common.py   View in Datadog   (Fix with Cursor)
assert '/opt/datadog-packages/datadog-agent/7.79.0\\embedded\\sbin\\gstatus' == '/opt/datadog-packages/datadog-agent/7.79.0/embedded/sbin/gstatus'
  
  - /opt/datadog-packages/datadog-agent/7.79.0/embedded/sbin/gstatus
  ?                                           ^        ^    ^
  + /opt/datadog-packages/datadog-agent/7.79.0\embedded\sbin\gstatus
  ?                                           ^        ^    ^
TestGetAgentEmbeddedPath::test_run_path_without_trailing_run from test_agent_common.py   View in Datadog   (Fix with Cursor)
assert '/custom/agent/dir\\embedded\\ssl\\certs\\cacert.pem' == '/custom/agent/dir/embedded/ssl/certs/cacert.pem'
  
  - /custom/agent/dir/embedded/ssl/certs/cacert.pem
  ?                  ^        ^   ^     ^
  + /custom/agent/dir\embedded\ssl\certs\cacert.pem
  ?                  ^        ^   ^     ^
TestGetAgentEmbeddedPath::test_standard_install from test_agent_common.py   View in Datadog   (Fix with Cursor)
assert '/opt/datadog-agent\\embedded\\sbin\\gstatus' == '/opt/datadog-agent/embedded/sbin/gstatus'
  
  - /opt/datadog-agent/embedded/sbin/gstatus
  ?                   ^        ^    ^
  + /opt/datadog-agent\embedded\sbin\gstatus
  ?                   ^        ^    ^
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 87.13% (-0.11%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bebd7a4 | Docs | Datadog PR Page | Give us feedback!

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.88%. Comparing base (9a1a9d6) to head (bebd7a4).
⚠️ Report is 92 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant