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

Bug #719325 reported by Christian Berendt on 2011-02-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
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

Soren Hansen (soren) wrote :

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

Thierry Carrez (ttx) wrote :

Christian: any suggestion ?

Changed in nova:
status: New → Incomplete
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) on 2011-02-15
Changed in nova:
importance: Undecided → Wishlist
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...

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) on 2011-04-15
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  Edit
Everyone can see this information.

Other bug subscribers