Logging in finding disk function fixed
The funcion find_existing_disk is called in the VolumeManager constructor. When the new node is discovered and nailgun-agent doesn't post yet nodes info to the Nailgun we have no volumes info and have warning and error messages in the logs on each VolumeManager object initialization. On empty volumes data we shouldn't perform search in find_existing_disk. Just log message and return None. Change-Id: Ia7ffc5f69995dc4230f5984faaa08ae543bbe044 Closes-Bug: #1523471
This commit is contained in:
parent
f6fe6375c4
commit
6bd08607c6
|
@ -674,6 +674,14 @@ class VolumeManager(object):
|
|||
|
||||
disks = only_disks(volumes)
|
||||
|
||||
if not disks:
|
||||
logger.debug("VolumeManager nothing to find in empty volumes "
|
||||
"by disk %s", disk_info)
|
||||
return None
|
||||
|
||||
logger.debug("VolumeManager finding disk by disk info: %s, "
|
||||
"in volumes: %s", disk_info, disks)
|
||||
|
||||
disk_info_composite_id = cls._build_disk_id_by_keys(
|
||||
disk_info, keys=('disk',), keys_for_lists=('extra',))
|
||||
disk_info_id_only = cls._build_disk_id_by_keys(
|
||||
|
|
|
@ -586,6 +586,13 @@ class TestVolumeManagerDisks(BaseTestCase):
|
|||
self.check_expected_volume_found_for_disk(disk_info, fake_volumes,
|
||||
fake_volumes[1])
|
||||
|
||||
def test_find_existing_disk_empty_volumes(self):
|
||||
disk_info = {'disk': 'disk_id', 'extra': []}
|
||||
with patch.object(VolumeManager, '_build_disk_id_by_keys') \
|
||||
as id_builder:
|
||||
self.assertIsNone(VolumeManager.find_existing_disk(disk_info, []))
|
||||
self.assertEqual(0, id_builder.call_count)
|
||||
|
||||
|
||||
class TestVolumeManager(BaseIntegrationTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue