Skip to content

[part 1] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  #4705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 18, 2025

Conversation

briannamagtoto
Copy link

@briannamagtoto briannamagtoto commented Jul 7, 2025

Summary

This PR implements detailed OS family detection for Linux-based ECS instances. Firstly, ECS-Init will parse through the instance's /etc/os-release file then pass it to the Agent through an env var (ECS_OS_FAMILY). This will be used in two ways:

  1. Amended to HTTPClient UserAgent string, as requested by PM team.
  2. [In Progress] Stored in an attribute ecs.os-type-detailed (will create part 2 PR for implementation).

Implementation details

  1. ecs-init parses /etc/os-release for ID and VERSION_ID fields
  2. Sets ECS_OS_FAMILY environment variable as ID_VERSION_ID
  3. Agent reads env var through config accessor
  4. Passes OS family to HTTP client

Testing

Unit tests have been added for OS release parsing, as well as environment variable handling tests, updated relevant parse_linux tests

New tests cover the changes: yes

Description for the changelog

Feature: Add detailed OS family value to HTTPClient User Agent header

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?
N/A

Does this PR include the addition of new environment variables in the README?
Yes

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…OS ENV Var, pass to httpclient, update README to include documentation for ECS_OS_FAMILY
@briannamagtoto briannamagtoto requested a review from a team as a code owner July 7, 2025 16:06
@briannamagtoto briannamagtoto marked this pull request as draft July 7, 2025 16:16
@briannamagtoto briannamagtoto changed the title Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  [WIP] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Jul 7, 2025
@briannamagtoto briannamagtoto reopened this Jul 7, 2025
@briannamagtoto briannamagtoto marked this pull request as ready for review July 7, 2025 18:10
@briannamagtoto briannamagtoto changed the title [WIP] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Jul 7, 2025
- Rename environment variable to ECS_DETAILED_OS_FAMILY and update README
- Replace exec cat command with os.ReadFile
- Refactor unit tests
- Move environment variable configuration to agent container
@briannamagtoto briannamagtoto force-pushed the feature/DetailedOSFamily branch 3 times, most recently from 5d67ae8 to d18c8ac Compare July 10, 2025 17:38
@briannamagtoto briannamagtoto changed the title Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  [WIP] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Jul 10, 2025
@briannamagtoto briannamagtoto marked this pull request as draft July 10, 2025 23:53
@briannamagtoto briannamagtoto force-pushed the feature/DetailedOSFamily branch 4 times, most recently from dc7b006 to 612b564 Compare July 14, 2025 16:43
@briannamagtoto
Copy link
Author

briannamagtoto commented Jul 14, 2025

Squashing commits (to debug Windows unit tests) into "Separate logic into GetOSFamily and GetDetailedOSFamily to maintain backward compatibility" 😅

@briannamagtoto briannamagtoto force-pushed the feature/DetailedOSFamily branch from d2c86e9 to 5d473bf Compare July 14, 2025 17:33
@briannamagtoto briannamagtoto marked this pull request as ready for review July 14, 2025 17:44
@briannamagtoto briannamagtoto changed the title [WIP] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Jul 14, 2025
sparrc
sparrc previously approved these changes Jul 15, 2025
mye956
mye956 previously approved these changes Jul 15, 2025
singholt
singholt previously approved these changes Jul 15, 2025
@singholt singholt self-requested a review July 15, 2025 22:21
… Linux os family files, add smallcomment providing details about /etc/os-release file
@briannamagtoto briannamagtoto dismissed stale reviews from singholt, mye956, and sparrc via 3b6644e July 15, 2025 23:04
@sparrc sparrc added bot/test and removed bot/test labels Jul 16, 2025
@briannamagtoto briannamagtoto changed the title Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  [part 1] Create function to parse Linux /etc/os-release files to set detailed OS ENV Var, pass to httpclient, update README  Jul 16, 2025
@briannamagtoto briannamagtoto requested review from mye956 and sparrc July 16, 2025 19:40
@briannamagtoto briannamagtoto merged commit fc76d1e into aws:dev Jul 18, 2025
40 checks passed
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.

6 participants