Skip to content

Handle Red Hat-family hosts without /etc/redhat-release - #461

Merged
swang392 merged 2 commits into
mainfrom
sarah.wang/ton-881-redhat-release-fallback
Oct 1, 2026
Merged

swang392 merged 2 commits into
mainfrom
sarah.wang/ton-881-redhat-release-fallback

Conversation

@swang392

@swang392 swang392 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes Red Hat-family release detection when /etc/redhat-release is missing.

Some images can still be classified as Red Hat-family through /etc/system-release, /etc/os-release, or /usr/lib/os-release, but the install path later parsed the major version only from /etc/redhat-release. When that file is absent, bash prints No such file or directory before the script falls back to 7.

This PR adds a helper that checks release metadata in order:

  • /etc/redhat-release
  • /etc/system-release
  • /etc/os-release
  • /usr/lib/os-release
  • existing fallback to 7

This keeps the existing behavior for normal RHEL/CentOS hosts and preserves the old fallback for hosts where none of the metadata files provide a numeric version.

Why?

TON-881 tracks an MCI install failure where the public Agent 7 install script reports missing /etc/redhat-release on a Red Hat-family host. The fix belongs here because MCI downloads the generated install_script_agent7.sh at runtime.

Testing

  • python3 unit_tests/extract_functions.py
  • focused no-sudo harness for get_redhat_release_version covering /etc/redhat-release, /etc/system-release, /etc/os-release, /usr/lib/os-release, nonnumeric VERSION_ID, fallback to 7, and missing-file stderr silence
  • make

I also tried ./unit_tests/test_install_script.sh locally with a temporary shunit2, but the full suite exercises existing sudo-based tests against /etc/datadog-agent/...; this machine is not configured for passwordless sudo, so I stopped it after sudo failures unrelated to this change.

Notes

This fixes the confirmed missing release metadata handling. It does not change yum repo URL construction or publish regenerated scripts; release/S3 publishing should happen through the normal follow-up flow.

Some Red Hat-family images can be detected through `system-release` or `os-release`, but the install path still parsed the major version only from `/etc/redhat-release`. Fall back through the same host metadata before keeping the existing default to `7`.
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ac977c2 | Docs | View more details | Give us feedback!

Shellcheck warns when a function references positional arguments but the production call site passes none. Pass the default release metadata paths explicitly so generated scripts keep the testable helper without triggering SC2119/SC2120.
@swang392
swang392 marked this pull request as ready for review September 30, 2026 20:20
@swang392
swang392 requested a review from a team as a code owner September 30, 2026 20:20
@swang392
swang392 merged commit 11c40bd into main Oct 1, 2026
354 checks passed
@swang392
swang392 deleted the sarah.wang/ton-881-redhat-release-fallback branch October 1, 2026 20:44
@julesmcrt julesmcrt mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants