Wait for udev to settle before listing the block devices
This patch is making the list_all_block_devices() method to wait for udev to settle it's event queue prior to listing the devices. Sometimes the ironic-python-agent service may start before all devices were detected and end up erroring out because it couldn't find a suitable disk for deployment. Closes-Bug: #1551300 Change-Id: I1ae2062a711115a1ea14b79ae9ace7ddd2fff9d5
This commit is contained in:
ironic_python_agent
releasenotes/notes
@ -49,6 +49,21 @@ def _get_device_vendor(dev):
|
||||
LOG.warning("Can't find the device vendor for device %s", dev)
|
||||
|
||||
|
||||
def _udev_settle():
|
||||
"""Wait for the udev event queue to settle.
|
||||
|
||||
Wait for the udev event queue to settle to make sure all devices
|
||||
are detected once the machine boots up.
|
||||
|
||||
"""
|
||||
try:
|
||||
utils.execute('udevadm', 'settle')
|
||||
except processutils.ProcessExecutionError as e:
|
||||
LOG.warning('Something went wrong when waiting for udev '
|
||||
'to settle. Error: %s', e)
|
||||
return
|
||||
|
||||
|
||||
def list_all_block_devices(block_type='disk'):
|
||||
"""List all physical block devices
|
||||
|
||||
@ -63,6 +78,8 @@ def list_all_block_devices(block_type='disk'):
|
||||
:return: A list of BlockDevices
|
||||
"""
|
||||
|
||||
_udev_settle()
|
||||
|
||||
columns = ['KNAME', 'MODEL', 'SIZE', 'ROTA', 'TYPE']
|
||||
report = utils.execute('lsblk', '-Pbdi', '-o{}'.format(','.join(columns)),
|
||||
check_exit_code=[0])[0]
|
||||
|
Reference in New Issue
Block a user