Merge lp:~larsks/cloud-init/fix-systemd-detection into lp:~cloud-init-dev/cloud-init/trunk
| Status: | Merged |
|---|---|
| Merged at revision: | 1112 |
| Proposed branch: | lp:~larsks/cloud-init/fix-systemd-detection |
| Merge into: | lp:~cloud-init-dev/cloud-init/trunk |
| Diff against target: |
102 lines (+37/-12) 4 files modified
cloudinit/distros/__init__.py (+8/-0) cloudinit/distros/rhel.py (+0/-8) tests/unittests/helpers.py (+6/-4) tests/unittests/test_distros/test_generic.py (+23/-0) |
| To merge this branch: | bzr merge lp:~larsks/cloud-init/fix-systemd-detection |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Dan Watkins | 2015-06-02 | Approve on 2015-06-10 | |
| Joshua Harlow | 2015-06-05 | Pending | |
|
Review via email:
|
|||
Description of the Change
check for systemd using sd_booted() semantics
The existing cloud-init code determines if systemd is in use by looking at the
distribution name and version. This is prone to error because:
- RHEL derivatives other than CentOS (e.g., Scientific Linux) will fail this test, and
- Distributions that are not derived from RHEL also use systemd
This patch makes cloud-init use the same logic that is used in systemd's
sd_booted() method
(http://
| Dan Watkins (daniel-thewatkins) wrote : | # |
- 1112. By Lars Kellogg-Stedman on 2015-06-03
-
transform paths in functions taking more than a single argument
Patch FilesystemMocki
ngTestcase. patchOS to support methods taking more
than a single path argument. This is required in order to properly mock
`os.symlink`, which takes two path arguments. - 1113. By Lars Kellogg-Stedman on 2015-06-03
-
add tests for systemd detection
This adds the following tests in test_distros.
test_generic: - test_systemd_in_use
Test the situation in which /run/systemd/system exists.
- test_systemd_
not_in_ use Test the situation in which /run/systemd/system does not exists.
- test_systemd_
symlink This tests the situation in which /run/systemd/system exists but is a
*symlink* to a directory, which according to sd_booted() should return
false.
| Lars Kellogg-Stedman (larsks) wrote : | # |
Dan,
Thanks for the review. I hope this addresses your suggestions.


Hi Lars,
Thanks for taking the time to do this, this looks like a good improvement.
Some tests for this would be good, to ensure that we don't regress here[0]. TestGenericDistro in tests/unittests /test_distros/ test_generic. py already has the means to do filesystem mocking in place, so it shouldn't be too painful.
Dan
[0] If I weren't looking at the code too carefully, I'd replace what you've written with os.path.isdir; but that would be incorrect because it follows symbolic links. Having something that makes us notice if someone does this would be valuable.