Bug #38081
openError 422 "unsupported configuration: unknown driver format value '' " while creating VM in Call to virDomainDefineXML
Description
We are running Foreman on Debian Bullseye and have installed foreman from the deb.theforeman.org mirror, pinned on minor Version 3.11.x.
After updating from 3.11.4 to 3.11.5 we encountered this Error while creating a VM.
HTTP POST "https://foreman.rz.babiel.com/api/v2/hosts": 422 Unprocessable Content: Failed to create a compute s099193 (Libvirt) instance s126043.rz.babiel.com: Error saving the server: Call to virDomainDefineXML failed: unsupported configuration: unknown driver format value ''
I pasted the production.log entry in the attached file below.
The POST Request to api/v2/hosts had following Parameters:
"host"=>{
"name"=>"s126043",
"hostgroup_id"=>901,
"root_pass"=>"[FILTERED]",
"compute_resource_id"=>134,
"compute_profile_id"=>3,
"compute_attributes"=>{
"cpus"=>4,
"memory"=>8589934592,
"volumes_attributes"=>{
"0"=>{
"capacity"=>"1G",
"allocation"=>"1G",
"pool_name"=>"vg1"
}
},
"start"=>"0"
},
"ip"=>"192.168.126.43",
"build"=>true,
"interfaces_attributes"=>[{
"compute_attributes"=>{
"bridge"=>"br126"
}
}]
},
"apiv"=>"v2"
So we do not change the volume.format_type. So the default Value 'raw' from foreman/vendor/ruby/2.7.0/gems/fog-libvirt-0.12.2/lib/fog/libvirt/models/compute/volume.rb should be used while generating the xml File for libvirts virDomainDefineXML API call.
But it seems like foreman version 3.11.5 and the XML-Creation changes in fog-libvirt 0.13.1 are incompatible.
3.11.4 works just fine, because of the offline shipped fog-libvirt version 0.12.2 in the .deb and the postinstall call to "bundle update" with the flag --local.
Files
Updated by Dorian Doeding about 2 months ago
So the default Value 'raw' from foreman/vendor/ruby/2.7.0/gems/fog-libvirt-0.12.2/lib/fog/libvirt/models/compute/volume.rb should be used while generating the xml File for libvirts virDomainDefineXML API call.
of course in case of Version 3.11.5 the path is foreman/vendor/ruby/2.7.0/gems/fog-libvirt-0.13.1/lib/fog/libvirt/models/compute/volume.rb
Updated by Maximilian Gaß about 9 hours ago
I work at the same company as the reporter and I did some further debugging.
It turns out, the problem is not that the default of format_type=raw gets lost. The problem is that the volume is created with Fog, and during that the volume_type turns to nil. Fog apparently reloads incorrectly here.
irb(main):002:0> compute = Fog::Compute.new(provider: :libvirt, libvirt_uri: "qemu+ssh://s098209.rz.babiel.com/system") => #<Fog::Libvirt::Compute::Real:32900 @uri=#<Fog::Libvirt::Util::URI:0x00005641ec957db8 @parsed_uri=#<URI::Generic qemu+ssh://s098209.rz.babiel.com/system>, @uri="qemu+ssh://s098209.... irb(main):003:0> vol = compute.volumes.new => <Fog::Libvirt::Compute::Volume ... irb(main):005:0> vol.format_type => "raw" irb(main):006:0> vol.save => <Fog::Libvirt::Compute::Volume id="mrhEsY-ngBd-bXIU-fo0c-GzW3-RARw-dPJbyu", pool_name="vg1", key="mrhEsY-ngBd-bXIU-fo0c-GzW3-RARw-dPJbyu", name="fog-604564504237723", path="/dev/vg1/fog-604564504237723", capacity=10, allocation=1, owner=nil, group=nil, format_type=nil, backing_volume=nil > irb(main):007:0> vol.format_type => nil
As you can see, vol.format_type is initially set to "raw" but then turns to nil. Passing volumes like to the Fog server (the VM) turns the format_type into an empty string, leading to the exception.
Updated by Maximilian Gaß about 9 hours ago
For comparison, this is with the working version, fog-libvirt 0.12.2:
irb(main):001:0> compute = Fog::Compute.new(provider: :libvirt, libvirt_uri: "qemu+ssh://s098209.rz.babiel.com/system") => #<Fog::Libvirt::Compute::Real:32900 @uri=#<Fog::Libvirt::Util::URI:0x00005644c0e01590 @parsed_uri=#<URI::Generic qemu+ssh://s098209.rz.babiel.com/system>, @uri="qemu+ssh://s098209.... irb(main):002:0> vol = compute.volumes.new => <Fog::Libvirt::Compute::Volume ... irb(main):003:0> vol.format_type => "raw" irb(main):004:0> vol.save => "/dev/vg1/fog-863102035852896" irb(main):005:0> vol.format_type => "raw"
Updated by Maximilian Gaß about 9 hours ago
Reported as https://github.com/fog/fog-libvirt/issues/169