Add a no-op wait method to NetworkInfo
The normal deploy flow uses a NetworkInfoAsyncWrapper for network allocation, and because of that many places have to call that class's wait method to make sure it has completed. During a reschedule where the network was allocated by a previous build attempt, a NetworkInfo instance is retrieved instead, which does not have a wait method. This then results in an exception complaining the missing method when it is called. This fix addresses that by adding a no-op wait method to the NetworkInfo class. Alternatively could have used isinstance or hasattr to avoid making wait calls on NetworkInfo, but that could be problematic to maintain as more places need to make wait calls in the future and may not know to make the isinstance/hasattr check. This fixes a regression issue caused by61fc1b9ee1, which reverted the previous fix made under24a04c405aChange-Id: Id7a71b2eb46ea7df19e7da0afbc0eafa87cac965 Closes-Bug: 1636109
This commit is contained in:
committed by
Matthew Edmonds
parent
bedd5abeca
commit
1b351ef535
@@ -4378,11 +4378,12 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
system_metadata={},
|
||||
expected_attrs=['system_metadata'])
|
||||
|
||||
self.compute._build_networks_for_instance(self.context, instance,
|
||||
self.requested_networks, self.security_groups)
|
||||
nw_info_obj = self.compute._build_networks_for_instance(self.context,
|
||||
instance, self.requested_networks, self.security_groups)
|
||||
|
||||
mock_allocate.assert_called_once_with(self.context, instance,
|
||||
self.requested_networks, None, self.security_groups, None)
|
||||
self.assertTrue(hasattr(nw_info_obj, 'wait'), "wait must be there")
|
||||
|
||||
@mock.patch.object(manager.ComputeManager, '_allocate_network')
|
||||
@mock.patch.object(network_api.API, 'get_instance_nw_info')
|
||||
@@ -4391,11 +4392,12 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
system_metadata=dict(network_allocated='False'),
|
||||
expected_attrs=['system_metadata'])
|
||||
|
||||
self.compute._build_networks_for_instance(self.context, instance,
|
||||
self.requested_networks, self.security_groups)
|
||||
nw_info_obj = self.compute._build_networks_for_instance(self.context,
|
||||
instance, self.requested_networks, self.security_groups)
|
||||
|
||||
mock_allocate.assert_called_once_with(self.context, instance,
|
||||
self.requested_networks, None, self.security_groups, None)
|
||||
self.assertTrue(hasattr(nw_info_obj, 'wait'), "wait must be there")
|
||||
|
||||
@mock.patch.object(network_api.API, 'setup_instance_network_on_host')
|
||||
@mock.patch.object(manager.ComputeManager, '_allocate_network')
|
||||
@@ -4409,8 +4411,9 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
def fake_network_info():
|
||||
return network_model.NetworkInfo([{'address': '123.123.123.123'}])
|
||||
|
||||
mock_get.return_value = network_model.NetworkInfoAsyncWrapper(
|
||||
fake_network_info)
|
||||
# this should be a NetworkInfo, not NetworkInfoAsyncWrapper, to match
|
||||
# what get_instance_nw_info really returns
|
||||
mock_get.return_value = fake_network_info()
|
||||
|
||||
self.compute._build_networks_for_instance(self.context, instance,
|
||||
self.requested_networks, self.security_groups)
|
||||
|
||||
Reference in New Issue
Block a user