From d8301748152e10ba64b4cebb79d4dad139988cea Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Thu, 24 Nov 2011 07:08:52 +0000 Subject: Remove boot-from-volume unreachable code path (#894172) In http://review.openstack.org/1834 it was discovered that a bool-from-volume code path in nova/compute/manager.py can never be reached. The code is basically: if ((bdm['snapshot_id'] is not None) and (bdm['volume_id'] is None)): vol = volume_api.create(context, ...) ... bdm['volume_id'] = vol['id'] if ((bdm['snapshot_id'] is not None) and (bdm['volume_id'] is None)): ... raise exception.ApiError(...) (after applying De Morgan's laws to the expression in the second if statement, that is) It's obvious that the code path can only be reached if the volume API's create() method can return a volume with id=None, but it can't ever do this. From: https://code.launchpad.net/~yamahata/nova/boot-from-volume-0/+merge/62419 it looks like the author originally had this check as an assertion, which makes more sense, but changed it to the current code following a review comment. Change-Id: I9f85028675f5dac8ab23bd150869eca421fc2fd0 --- nova/compute/manager.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 2f0b0c71c..5f0d522d6 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -303,17 +303,6 @@ class ComputeManager(manager.SchedulerDependentManager): context, bdm['id'], {'volume_id': vol['id']}) bdm['volume_id'] = vol['id'] - if not ((bdm['snapshot_id'] is None) or - (bdm['volume_id'] is not None)): - LOG.error(_('corrupted state of block device mapping ' - 'id: %(id)s snapshot: %(snapshot_id)s ' - 'volume: %(volume_id)s') % - {'id': bdm['id'], - 'snapshot_id': bdm['snapshot'], - 'volume_id': bdm['volume_id']}) - raise exception.ApiError(_('broken block device mapping %d') % - bdm['id']) - if bdm['volume_id'] is not None: volume_api.check_attach(context, volume_id=bdm['volume_id']) -- cgit