Setting cpu-model, buut cpu-mode not 'custom' creates an invalid config and brings the service down

Bug #1944484 reported by Jose Guedez
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Nova Compute Charm
Triaged
Medium
Unassigned

Bug Description

Versions:
* charm: stable/21.01
* nova-compute: 21.2.0-0ubuntu1

The description for the `cpu-model` config option mentions that it only has effect if `cpu_mode` is custom:

  cpu-model:
    description: |
      Set to a named libvirt CPU model (see names listed in
      /usr/share/libvirt/cpu_map.xml). Only has effect if cpu_mode='custom' and
      virt_type='kvm|qemu'.
    source: user
    type: string
    value: ""

However, setting it to a valid value like "EPYC-Rome", when `cpu-mode` is set to `host-passthrough` results in an invalid configuration and a nova-compute service restart that brings it down with a stacktrace in the logs (below).

It would be helpful to prevent writing an invalid configuration and restarting the service (as well as updating the configuration description, since changing the value does have an effect when `cpu-mode` != "custom"

2021-09-22 00:41:28.328 301988 ERROR oslo_service.service [-] Error starting thread.: nova.exception.Invalid: The cpu_models option is not required when cpu_mode!=custom
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service Traceback (most recent call last):
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service File "/usr/lib/python3/dist-packages/oslo_service/service.py", line 810, in run_service
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service service.start()
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service File "/usr/lib/python3/dist-packages/nova/service.py", line 173, in start
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service self.manager.init_host()
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service File "/usr/lib/python3/dist-packages/nova/compute/manager.py", line 1404, in init_host
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service self.driver.init_host(host=self.host)
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service File "/usr/lib/python3/dist-packages/nova/virt/libvirt/driver.py", line 743, in init_host
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service self._check_cpu_compatibility()
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service File "/usr/lib/python3/dist-packages/nova/virt/libvirt/driver.py", line 761, in _check_cpu_compati
bility
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service raise exception.Invalid(msg)
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service nova.exception.Invalid: The cpu_models option is not required when cpu_mode!=custom
2021-09-22 00:41:28.328 301988 ERROR oslo_service.service

Revision history for this message
Felipe Reyes (freyes) wrote :

Something like this should be safe guarding the cpu_model.

diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py
index 74f8f92..2fc40c6 100644
--- a/hooks/nova_compute_context.py
+++ b/hooks/nova_compute_context.py
@@ -241,7 +241,7 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
         elif ctxt['arch'] == 's390x':
             ctxt['cpu_mode'] = 'none'

- if config('cpu-model'):
+ if config('cpu-model') and ctxt['cpu_mode'] == 'custom' and config('virt-type') in ['kvm', 'qemu']:
             ctxt['cpu_model'] = config('cpu-model')

         if config('cpu-model-extra-flags'):

Changed in charm-nova-compute:
status: New → Triaged
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.