fix: Consider "degraded" systemd state as booted#217
Merged
richm merged 3 commits intolinux-system-roles:mainfrom May 14, 2025
Merged
fix: Consider "degraded" systemd state as booted#217richm merged 3 commits intolinux-system-roles:mainfrom
richm merged 3 commits intolinux-system-roles:mainfrom
Conversation
This was a thinko in commit 7a7a323.
Suggested by sourcery.ai.
This gives an early explicit error message rather than more cryptic ones later on. We already use this in other roles (tlog, logging), copied from there.
Reviewer's GuideRefactors Ansible systemd boot detection to treat 'degraded' state as booted, introduces a pre-check for systemd installation, and cleans up conditional syntax for readability. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @martinpitt - I've reviewed your changes - here's some feedback:
- Rather than matching on an error string in
__is_system_running.msg, use the command’s return code (e.g.when: __is_system_running.rc != 0) to detect missing systemd and avoid locale/version issues. - Normalize the
systemctl is-system-runningoutput (e.g.stdout|trim|lower) before comparison to guard against trailing whitespace or case differences.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Review instructions: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Comment on lines
+18
to
+21
| - name: Require installed systemd | ||
| fail: | ||
| msg: "Error: This role requires systemd to be installed." | ||
| when: '"No such file or directory" in __is_system_running.msg | d("")' |
There was a problem hiding this comment.
suggestion: Use explicit binary existence check or Ansible fact instead of parsing error message
Use the stat module to check for /usr/bin/systemctl or use the ansible_service_mgr fact instead of parsing error output. This avoids fragility from output changes or localization.
Suggested change
| - name: Require installed systemd | |
| fail: | |
| msg: "Error: This role requires systemd to be installed." | |
| when: '"No such file or directory" in __is_system_running.msg | d("")' | |
| - name: Check for systemctl binary | |
| stat: | |
| path: /usr/bin/systemctl | |
| register: systemctl_stat | |
| - name: Require installed systemd | |
| fail: | |
| msg: "Error: This role requires systemd to be installed." | |
| when: not systemctl_stat.stat.exists |
richm
approved these changes
May 14, 2025
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.
This was a thinko in commit 7a7a323.
Plus some cleanups.
Summary by Sourcery
Fix systemd boot detection to treat 'degraded' state as booted, add a guard for missing systemd installation, and standardize Ansible 'when' checks.
Bug Fixes:
Enhancements: