Conversation
Replace `get_release_file_path` function with `get_release_file_content` that tries to access `/var/lib/snapd/hostfs/etc/os-release`. If this file doesn't exist, it means we are not calling the script from within a snap, so it tries to access `/etc/os-release` instead. `get_release_info` now takes the content of the `os-release` file as parameter and ignores empty lines.
Hook25
previously approved these changes
Mar 10, 2025
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1786 +/- ##
=======================================
Coverage 49.81% 49.82%
=======================================
Files 377 377
Lines 40701 40703 +2
Branches 6844 6846 +2
=======================================
+ Hits 20277 20279 +2
Misses 19700 19700
Partials 724 724
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hook25
approved these changes
Mar 10, 2025
stanley31huang
pushed a commit
that referenced
this pull request
Mar 28, 2025
* Default to content from /etc/os-release Replace `get_release_file_path` function with `get_release_file_content` that tries to access `/var/lib/snapd/hostfs/etc/os-release`. If this file doesn't exist, it means we are not calling the script from within a snap, so it tries to access `/etc/os-release` instead. `get_release_info` now takes the content of the `os-release` file as parameter and ignores empty lines. * Add unit tests * Update graphics_card_resource.py to use the new function * Fix Flake8 errors
mreed8855
pushed a commit
that referenced
this pull request
Jul 31, 2025
* Default to content from /etc/os-release Replace `get_release_file_path` function with `get_release_file_content` that tries to access `/var/lib/snapd/hostfs/etc/os-release`. If this file doesn't exist, it means we are not calling the script from within a snap, so it tries to access `/etc/os-release` instead. `get_release_info` now takes the content of the `os-release` file as parameter and ignores empty lines. * Add unit tests * Update graphics_card_resource.py to use the new function * Fix Flake8 errors
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.
Description
Replace
get_release_file_pathfunction withget_release_file_contentthat tries to access
/var/lib/snapd/hostfs/etc/os-release. If thisfile doesn't exist, it means we are not calling the script from within a
snap, so it tries to access
/etc/os-releaseinstead.get_release_infonow takes the content of theos-releasefile asparameter and ignores empty lines.
The issue was introduced with previous PR #1748
Resolved issues
Prevent the os resource job from failing like this (example found the submission from a run using Checkbox in the edge channel):
{ "id": "lsb", "full_id": "com.canonical.certification::lsb", "name": "[DEPRECATED, use 'os' instead] Collect information about installed operating system (os-release)", "certification_status": "non-blocker", "category": "Gathers information about the DUT", "category_id": "com.canonical.certification::information_gathering", "status": "fail", "outcome": "fail", "comments": null, "io_log": "Traceback (most recent call last):\n File \"/tmp/nest-kopwzdp5.810b3c2c743e7de21a0c69775e0ca9675ca511eed3b76c394124412985b763db/os_resource.py\", line 57, in <module>\n sys.exit(main())\n File \"/tmp/nest-kopwzdp5.810b3c2c743e7de21a0c69775e0ca9675ca511eed3b76c394124412985b763db/os_resource.py\", line 51, in main\n release_info = get_release_info(release_file_path)\n File \"/tmp/nest-kopwzdp5.810b3c2c743e7de21a0c69775e0ca9675ca511eed3b76c394124412985b763db/os_resource.py\", line 39, in get_release_info\n with open(release_file_path, \"r\") as lsb:\nFileNotFoundError: [Errno 2] No such file or directory: '/var/lib/snapd/hostfs/etc/os-release'\n", "type": "test", "project": "certification", "duration": 0.15081572532653809, "plugin": "resource", "template_id": null },Documentation
Tests