Skip to content

Commit a931b0b

Browse files
committed
Revert "[pwmgmt]ignore missin governor when cpu_state used"
This reverts commit 41096f8 as it has a bug in it expecting a wrong exception type (FileNotFoundError vs nova.exception.FileNotFound). Also there is a proper fix on master 2c44215 that can be backported instead. Change-Id: Id2c253a6e223bd5ba22512d9e5a40a9d12680da2 (cherry picked from commit 03ef4d6) (cherry picked from commit 25d0db7)
1 parent 683ecc0 commit a931b0b

File tree

2 files changed

+1
-57
lines changed

2 files changed

+1
-57
lines changed

nova/tests/unit/virt/libvirt/cpu/test_api.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -237,42 +237,3 @@ def test_validate_all_dedicated_cpus_no_cpu(self):
237237
api.validate_all_dedicated_cpus()
238238
# no assert we want to make sure the validation won't raise if
239239
# no dedicated cpus are configured
240-
241-
@mock.patch.object(core, 'get_governor')
242-
@mock.patch.object(core, 'get_online')
243-
def test_validate_all_dedicated_cpus_for_cpu_state_no_governor_ignored(
244-
self, mock_get_online, mock_get_governor
245-
):
246-
self.flags(cpu_power_management=True, group='libvirt')
247-
self.flags(cpu_dedicated_set='0-2', group='compute')
248-
self.flags(cpu_power_management_strategy='cpu_state', group='libvirt')
249-
250-
mock_get_online.return_value = True
251-
mock_get_governor.side_effect = FileNotFoundError(
252-
"File /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "
253-
"could not be found.")
254-
255-
api.validate_all_dedicated_cpus()
256-
257-
self.assertEqual(2, len(mock_get_governor.mock_calls))
258-
259-
@mock.patch.object(core, 'get_governor')
260-
@mock.patch.object(core, 'get_online')
261-
def test_validate_all_dedicated_cpus_for_governor_error(
262-
self, mock_get_online, mock_get_governor
263-
):
264-
self.flags(cpu_power_management=True, group='libvirt')
265-
self.flags(cpu_dedicated_set='0-2', group='compute')
266-
self.flags(cpu_power_management_strategy='governor', group='libvirt')
267-
268-
mock_get_online.return_value = True
269-
mock_get_governor.side_effect = FileNotFoundError(
270-
"File /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor "
271-
"could not be found.")
272-
273-
ex = self.assertRaises(
274-
exception.InvalidConfiguration, api.validate_all_dedicated_cpus)
275-
self.assertIn(
276-
"[libvirt]cpu_power_management_strategy is 'governor', "
277-
"but the host OS does not support governors for CPU0",
278-
str(ex))

nova/virt/libvirt/cpu/api.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,7 @@ def validate_all_dedicated_cpus() -> None:
137137
continue
138138
pcpu = Core(pcpu)
139139
# we need to collect the governors strategy and the CPU states
140-
try:
141-
governors.add(pcpu.governor)
142-
except FileNotFoundError as e:
143-
# NOTE(gibi): When
144-
# /sys/devices/system/cpu/cpuX/cpufreq/scaling_governor does
145-
# not exist it means the host OS does not support any governors.
146-
# If cpu_state strategy is requested we can ignore this as
147-
# governors will not be used but if governor strategy is requested
148-
# we need to report an error and stop as the host is not properly
149-
# configured
150-
if CONF.libvirt.cpu_power_management_strategy == 'governor':
151-
msg = _(
152-
"[libvirt]cpu_power_management_strategy is 'governor', "
153-
"but the host OS does not support governors for CPU%d"
154-
% pcpu.ident
155-
)
156-
raise exception.InvalidConfiguration(msg) from e
157-
140+
governors.add(pcpu.governor)
158141
cpu_states.add(pcpu.online)
159142
if CONF.libvirt.cpu_power_management_strategy == 'cpu_state':
160143
# all the cores need to have the same governor strategy

0 commit comments

Comments
 (0)