Setting cpu-model, buut cpu-mode not 'custom' creates an invalid config and brings the service down
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
/
virt_
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.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
bility
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
2021-09-22 00:41:28.328 301988 ERROR oslo_service.
Something like this should be safe guarding the cpu_model.
diff --git a/hooks/ nova_compute_ context. py b/hooks/ nova_compute_ context. py nova_compute_ context. py nova_compute_ context. py irtContext( context. OSContextGenera tor):
ctxt[ 'cpu_mode' ] = 'none'
index 74f8f92..2fc40c6 100644
--- a/hooks/
+++ b/hooks/
@@ -241,7 +241,7 @@ class NovaComputeLibv
elif ctxt['arch'] == 's390x':
- if config( 'cpu-model' ):
ctxt[ 'cpu_model' ] = config('cpu-model')
+ if config('cpu-model') and ctxt['cpu_mode'] == 'custom' and config('virt-type') in ['kvm', 'qemu']:
if config( 'cpu-model- extra-flags' ):