Attach a volume with scsi bus on an instance boot from cdrom fails

Bug #1801342 reported by Jose Castro Leon
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
In Progress
Undecided
Jose Castro Leon

Bug Description

Following the upstream documentation to create images from an ISO (https://docs.openstack.org/nova/rocky/user/launch-instance-using-ISO-image.html) with an image from a vendor that required to have the disk attached on the scsi bus (/dev/sda) in order to install the system, it failed on attach volume step with the following traceback:

Driver failed to attach volume 95b42945-5d2a-4fba-b970-1d3fafcfbecc at /dev/sda: ValueError: max() arg is an empty sequence
Traceback (most recent call last):
   File "/usr/lib/python2.7/site-packages/nova/virt/block_device.py", line 538, in _volume_attach
     device_type=self['device_type'], encryption=encryption)
   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1451, in attach_volume
     disk_info['unit'] = self._get_scsi_controller_max_unit(guest) + 1
   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1134, in _get_scsi_controller_max_unit
     return max(ret)
 ValueError: max() arg is an empty sequence

Looking at the code

    def _get_scsi_controller_max_unit(self, guest):
        """Returns the max disk unit used by scsi controller"""
        xml = guest.get_xml_desc()
        tree = etree.fromstring(xml)
        addrs = "./devices/disk[@device='disk']/address[@type='drive']"

        ret = []
        for obj in tree.findall(addrs):
            ret.append(int(obj.get('unit', 0)))
        return max(ret)

As the instance has no existing devices in the scsi device bus, then the ret array is empty and the max function just fails with the traceback mentioned above.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/615141

Changed in nova:
assignee: nobody → Jose Castro Leon (jose-castro-leon)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Lee Yarwood (<email address hidden>) on branch: master
Review: https://review.opendev.org/615141

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.