From cb02486816e646f6b60d973f0e43bdb61b375c5b Mon Sep 17 00:00:00 2001 From: ankitagrawal Date: Wed, 23 Sep 2015 03:18:12 -0700 Subject: [PATCH] Remove unnecessary call to info_cache.delete Removed unnecessary call to instance.info_cache.delete from _local_delete method because info_cache is deleted by calling instance.destroy from _local_delete. Also it raises InstanceInfoCacheNotFound exception in a race condition when instance.refresh is called after info_cache is deleted by this call. Partial-Bug: 1404867 Change-Id: Ia76ded06a9ce014fb5d9cb35a03ae868d5106ba1 --- nova/compute/api.py | 8 -------- nova/tests/unit/compute/test_compute_api.py | 4 ---- 2 files changed, 12 deletions(-) diff --git a/nova/compute/api.py b/nova/compute/api.py index 6697f2e2911a..03845be69544 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1803,14 +1803,6 @@ class API(base.Base): else: LOG.warning(_LW("instance's host %s is down, deleting from " "database"), instance.host, instance=instance) - if instance.info_cache is not None: - instance.info_cache.delete() - else: - # NOTE(yoshimatsu): Avoid AttributeError if instance.info_cache - # is None. When the root cause that instance.info_cache becomes - # None is fixed, the log level should be reconsidered. - LOG.warning(_LW("Info cache for instance could not be found. " - "Ignore."), instance=instance) compute_utils.notify_about_instance_usage( self.notifier, context, instance, "%s.start" % delete_type) diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 4677c8b8b5b4..b43a00f33de6 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -740,7 +740,6 @@ class _ComputeAPIUnitTestMixIn(object): test.TestingException("Unexpected error")) def _test_downed_host_part(self, inst, updates, delete_time, delete_type): - inst.info_cache.delete() compute_utils.notify_about_instance_usage( self.compute_api.notifier, self.context, inst, '%s.start' % delete_type) @@ -792,7 +791,6 @@ class _ComputeAPIUnitTestMixIn(object): self.mox.StubOutWithMock(compute_utils, 'reserve_quota_delta') self.mox.StubOutWithMock(self.compute_api, '_record_action_start') self.mox.StubOutWithMock(db, 'instance_update_and_get_original') - self.mox.StubOutWithMock(inst.info_cache, 'delete') self.mox.StubOutWithMock(self.compute_api.network_api, 'deallocate_for_instance') self.mox.StubOutWithMock(db, 'instance_system_metadata_get') @@ -1029,7 +1027,6 @@ class _ComputeAPIUnitTestMixIn(object): self.mox.StubOutWithMock(inst, 'destroy') self.mox.StubOutWithMock(self.context, 'elevated') - self.mox.StubOutWithMock(inst.info_cache, 'delete') self.mox.StubOutWithMock(self.compute_api.network_api, 'deallocate_for_instance') self.mox.StubOutWithMock(db, 'instance_system_metadata_get') @@ -1039,7 +1036,6 @@ class _ComputeAPIUnitTestMixIn(object): 'terminate_connection') self.mox.StubOutWithMock(objects.BlockDeviceMapping, 'destroy') - inst.info_cache.delete() compute_utils.notify_about_instance_usage( self.compute_api.notifier, self.context, inst, 'delete.start')