Reject customized cpu_mode for unsupported virt_type

Using cpu_mode other than 'none' is supported only when virt_type is
qemu or kvm and nova-compute fails to start in case an unsupported
combination is used. Enforce this requirement during deployment to
make the invalid configuration more visible.

Change-Id: If9fc59797c4a24a3b7536cd3fe8770316fdf4f4d
This commit is contained in:
Takashi Kajinami
2024-07-11 13:21:09 +09:00
parent a5e5529a67
commit 554d7b1ce0
2 changed files with 14 additions and 0 deletions

View File

@@ -298,6 +298,9 @@ class nova::compute::libvirt (
}
}
} else {
if $cpu_mode != 'none' and !($virt_type in ['qemu', 'kvm']) {
fail("\$virt_type = \"${virt_type}\" supports only \$cpu_mode = \"none\"")
}
$cpu_mode_real = $cpu_mode
}

View File

@@ -164,6 +164,17 @@ describe 'nova::compute::libvirt' do
it { is_expected.to contain_nova_config('libvirt/cpu_model_extra_flags').with_value('pcid')}
end
context 'with cpu_mode and non qemu/kvm virt_type' do
let :params do
{
:cpu_mode => 'host-passthrough',
:virt_type => 'lxc',
}
end
it { should raise_error(Puppet::Error, /\$virt_type = "lxc" supports only \$cpu_mode = "none"/) }
end
context 'with non-custom cpu_node and cpu_models' do
let :params do
{ :cpu_models => ['kvm64', 'qemu64'] }