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
(cherry picked from commit 6bd08607c6)
This commit is contained in:
Alexander Kislitsky 2015-12-08 11:15:09 +03:00 committed by Anton Chevychalov
parent 44cf6f8a67
commit 63f079884b
2 changed files with 15 additions and 0 deletions

View File

@ -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(

View File

@ -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):