Handle Red Hat-family hosts without /etc/redhat-release - #461
Merged
Merged
Conversation
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`.
🎉 All green!🧪 All tests passed 🔗 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.
fanny-jiang
approved these changes
Sep 30, 2026
rahulkaukuntla
approved these changes
Oct 1, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes Red Hat-family release detection when
/etc/redhat-releaseis 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 printsNo such file or directorybefore the script falls back to7.This PR adds a helper that checks release metadata in order:
/etc/redhat-release/etc/system-release/etc/os-release/usr/lib/os-release7This 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-releaseon a Red Hat-family host. The fix belongs here because MCI downloads the generatedinstall_script_agent7.shat runtime.Testing
python3 unit_tests/extract_functions.pyget_redhat_release_versioncovering/etc/redhat-release,/etc/system-release,/etc/os-release,/usr/lib/os-release, nonnumericVERSION_ID, fallback to7, and missing-file stderr silencemakeI also tried
./unit_tests/test_install_script.shlocally with a temporaryshunit2, 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.