Merge ~dnegreira/charm-sysconfig:1873028 into charm-sysconfig:master

Proposed by David Negreira
Status: Merged
Approved by: Alvaro Uria
Approved revision: c8c1908b5914c7b4053d103b96428118517c86c0
Merged at revision: 671c8a0ce47a39ba97968d0868db02f463402bfc
Proposed branch: ~dnegreira/charm-sysconfig:1873028
Merge into: charm-sysconfig:master
Diff against target: 97 lines (+6/-14)
2 files modified
src/lib/lib_sysconfig.py (+2/-2)
src/tests/unit/test_lib.py (+4/-12)
Reviewer Review Type Date Requested Status
Alvaro Uria (community) Approve
Xav Paice (community) Approve
Review via email: mp+382430@code.launchpad.net

Commit message

Disable ondemand for all series

Disable ondemand systemd unit when a different governor is configured
for the current LTS releases as well as future ones as the ondemand
systemd unit is still included by default.

Closes-Bug: #1873028

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM.

I tested also on a system without the ondemand.service, and it didn't produce any errors - though it might be cleaner to ensure the service exists before masking it. Can consider that for a second change in the future if we decide it's valuable.

review: Approve
Revision history for this message
David Negreira (dnegreira) wrote :

Hi,

When can this fix land?

Thanks,
David Negreira.

Revision history for this message
Alvaro Uria (aluria) wrote :

lgtm +1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 671c8a0ce47a39ba97968d0868db02f463402bfc

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lib/lib_sysconfig.py b/src/lib/lib_sysconfig.py
2index 7d4513d..0acf239 100644
3--- a/src/lib/lib_sysconfig.py
4+++ b/src/lib/lib_sysconfig.py
5@@ -367,7 +367,7 @@ class SysConfigHelper:
6 self._render_boot_resource(CPUFREQUTILS_TMPL, CPUFREQUTILS, context)
7 # Ensure the ondemand service is disabled if governor is set, lp#1822774, lp#1863659, lp#740127
8 # Ondemand service is not updated during test if host is container.
9- if host.get_distrib_codename() == 'xenial' and not host.is_container():
10+ if not host.is_container():
11 hookenv.log('disabling the ondemand services for lp#1822774, lp#1863659,'
12 ' and lp#740127 if a governor is specified', hookenv.DEBUG)
13 if self.governor:
14@@ -431,7 +431,7 @@ class SysConfigHelper:
15 Will render cpufrequtils config with empty context.
16 """
17 context = {}
18- if host.get_distrib_codename() == 'xenial' and not host.is_container():
19+ if not host.is_container():
20 hookenv.log('Enabling the ondemand initscript for lp#1822774'
21 ' and lp#740127', 'DEBUG')
22 subprocess.call(
23diff --git a/src/tests/unit/test_lib.py b/src/tests/unit/test_lib.py
24index 455018b..b3e5fd1 100644
25--- a/src/tests/unit/test_lib.py
26+++ b/src/tests/unit/test_lib.py
27@@ -118,17 +118,15 @@ class TestLib:
28 assert isinstance(sysconfig.charm_config, dict)
29
30 @mock.patch("lib_sysconfig.subprocess.call")
31- @mock.patch("lib_sysconfig.host.get_distrib_codename")
32 @mock.patch("lib_sysconfig.hookenv.config")
33 @mock.patch("lib_sysconfig.host.service_restart")
34 @mock.patch("lib_sysconfig.render")
35- def test_update_cpufreq(self, render, restart, config, codename, check_call):
36+ def test_update_cpufreq(self, render, restart, config, check_call):
37 """Set config governor=performance.
38
39 Expect /etc/default/cpufrequtils is rendered
40 and ondemand init script removed
41 """
42- codename.return_value = "xenial"
43 expected = {"governor": "performance"}
44 config.return_value = expected
45 sysh = lib_sysconfig.SysConfigHelper()
46@@ -144,17 +142,15 @@ class TestLib:
47 stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
48
49 @mock.patch("lib_sysconfig.subprocess.call")
50- @mock.patch("lib_sysconfig.host.get_distrib_codename")
51 @mock.patch("lib_sysconfig.hookenv.config")
52 @mock.patch("lib_sysconfig.host.service_restart")
53 @mock.patch("lib_sysconfig.render")
54- def test_update_cpufreq_governor_default(self, render, restart, config, codename, check_call):
55+ def test_update_cpufreq_governor_default(self, render, restart, config, check_call):
56 """Set config governor=''.
57
58 Expect /etc/default/cpufrequtils is rendered with no governor
59 and ondemand init script is installed
60 """
61- codename.return_value = "xenial"
62 expected = {"governor": ""}
63 config.return_value = expected
64 sysh = lib_sysconfig.SysConfigHelper()
65@@ -171,16 +167,14 @@ class TestLib:
66 stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
67
68 @mock.patch("lib_sysconfig.subprocess.call")
69- @mock.patch("lib_sysconfig.host.get_distrib_codename")
70 @mock.patch("lib_sysconfig.hookenv.config")
71 @mock.patch("lib_sysconfig.host.service_restart")
72 @mock.patch("lib_sysconfig.render")
73- def test_update_cpufreq_governor_not_available(self, render, restart, config, codename, check_call):
74+ def test_update_cpufreq_governor_not_available(self, render, restart, config, check_call):
75 """Set wrong governor.
76
77 Expect /etc/default/cpufrequtils is not rendered
78 """
79- codename.return_value = "xenial"
80 expected = {"governor": "wrong"}
81 config.return_value = expected
82 sysh = lib_sysconfig.SysConfigHelper()
83@@ -497,14 +491,12 @@ class TestLib:
84 @mock.patch("lib_sysconfig.render")
85 @mock.patch("lib_sysconfig.host.service_restart")
86 @mock.patch("lib_sysconfig.subprocess.call")
87- @mock.patch("lib_sysconfig.host.get_distrib_codename")
88 @mock.patch("lib_sysconfig.hookenv.log")
89- def test_remove_cpufreq_configuration_xenial(self, log, distrib_codename, check_call, restart, render, config):
90+ def test_remove_cpufreq_configuration_xenial(self, log, check_call, restart, render, config):
91 """Test remove cpufrequtlis configuration.
92
93 Expect config is rendered with empty context.
94 """
95- distrib_codename.return_value = "xenial"
96 sysh = lib_sysconfig.SysConfigHelper()
97 sysh.remove_cpufreq_configuration()
98

Subscribers

People subscribed via source and target branches

to all changes: