implement clean test to check if device is coming up after using qemu-nbd

Bug #719325 reported by Christian Berendt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Wishlist
Unassigned

Bug Description

I don't like the used test (sleeping for 1 second and recheck afterwards). Please implement some clean test to check if the device is coming up after running qemu-nbd...

in nova/virt/disk.py:

def _link_device(image, nbd):
    """Link image to device using loopback or nbd"""
    if nbd:
        device = _allocate_device()
        utils.execute('sudo qemu-nbd -c %s %s' % (device, image))
        # NOTE(vish): this forks into another process, so give it a chance
        # to set up before continuuing
        for i in xrange(10):
            if os.path.exists("/sys/block/%s/pid" % os.path.basename(device)):
                return device
            time.sleep(1)
        raise exception.Error(_('nbd device %s did not show up') % device)
    else:
        out, err = utils.execute('sudo losetup --find --show %s' % image)
        if err:
            raise exception.Error(_('Could not attach image to loopback: %s')
                                  % err)
        return out.strip()

Related branches

Revision history for this message
Soren Hansen (soren) wrote :

I'm afraid this is the best we can do. nbd is notoriously difficult to get feedback from.

Revision history for this message
Thierry Carrez (ttx) wrote :

Christian: any suggestion ?

Changed in nova:
status: New → Incomplete
Revision history for this message
Christian Berendt (berendt) wrote :

Not at the moment.. if you think this is the best solution and it's working fine.. But generally I think it's no clean solution and we should change it to something different.

Because it's working at the moment I change priority to low. Can somebody move it to the wishlist, I can't do that...

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Wishlist
Revision history for this message
Christian Berendt (berendt) wrote :

Seems to be the best solution for waiting for an upcoming NBD device. But I think we sould introduce a flag to manually configure the timeout, I had a system where it took 20 seconds or so...

Revision history for this message
Christian Berendt (berendt) wrote :

I added a new flag for setting the timeout via /etc/nova/nova.conf. The check itself is working fined and should not be modified.

Changed in nova:
status: Incomplete → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.2
status: Fix Committed → Fix Released
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.