Allow udev events to complete

It is possible that the udev events will be triggered, the hook
execution finished, another hook fires, and a second attempt to
mount the devices happens despite a check if a device is mounted.
By allowing udev events to settle, any mounts desired should be
attempted before completing hook execution.

Change-Id: Iaf8f0edf31084894fdd73fab99f750905476c4cf
Partial-Bug: #1746118
This commit is contained in:
Chris MacNaughton 2018-02-12 10:14:18 +01:00
parent ad2d606b0c
commit 523d76db44
2 changed files with 24 additions and 0 deletions

View File

@ -1008,6 +1008,9 @@ def rescan_osd_devices():
subprocess.call(cmd)
cmd = ['udevadm', 'settle']
subprocess.call(cmd)
_bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring"
_upgrade_keyring = "/var/lib/ceph/osd/ceph.client.osd-upgrade.keyring"

View File

@ -46,6 +46,27 @@ class CephTestCase(unittest.TestCase):
def setUp(self):
super(CephTestCase, self).setUp()
@patch.object(utils, 'cmp_pkgrevno')
@patch.object(utils.subprocess, 'call')
@patch.object(utils.os.path, 'exists')
@patch.object(utils.os.path, 'isdir')
def test_start_osd(self,
_isdir,
_exists,
_call,
_pkgrevno):
_pkgrevno.return_value = True
_isdir.return_value = False
utils.start_osds(['/dev/sdb'])
_isdir.assert_called_once_with('/dev/sdb')
_exists.assert_called_once_with('/dev/sdb')
_call.assert_has_calls([
call(['udevadm', 'trigger',
'--subsystem-match=block', '--action=add'
]),
call(['udevadm', 'settle']),
])
@patch.object(utils.subprocess, 'check_call')
@patch.object(utils.os.path, 'exists')
@patch.object(utils, 'is_device_mounted')