diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-12 23:59:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-12 23:59:59 +0000 |
| commit | b0694b33d3a7c32b582030d44231ef31bcc8ec60 (patch) | |
| tree | d0a5a1b1a273e8c60738e8c9e94e68808ec2dc8e /nova/compute | |
| parent | 071719a3e16b747bc9c2cdadab829c3c1287eede (diff) | |
| parent | 40feb35898ed0a6d57b1f481c165e683796b045c (diff) | |
Merge "xenapi: Fix reboot with hung volumes"
Diffstat (limited to 'nova/compute')
| -rwxr-xr-x | nova/compute/manager.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index bb1447da4..24b79a0ab 100755 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1582,6 +1582,32 @@ class ComputeManager(manager.SchedulerDependentManager): network_info=network_info, extra_usage_info=extra_usage_info) + def _handle_bad_volumes_detached(self, context, instance, bad_devices, + block_device_info): + """Handle cases where the virt-layer had to detach non-working volumes + in order to complete an operation. + """ + for bdm in block_device_info['block_device_mapping']: + if bdm.get('mount_device') in bad_devices: + try: + volume_id = bdm['connection_info']['data']['volume_id'] + except KeyError: + continue + + # NOTE(sirp): ideally we'd just call + # `compute_api.detach_volume` here but since that hits the + # DB directly, that's off limits from within the + # compute-manager. + # + # API-detach + LOG.info(_("Detaching from volume api: %s") % volume_id) + volume = self.volume_api.get(context, volume_id) + self.volume_api.check_detach(context, volume) + self.volume_api.begin_detaching(context, volume) + + # Manager-detach + self.detach_volume(context, volume_id, instance) + @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @reverts_task_state @wrap_instance_event @@ -1616,10 +1642,16 @@ class ComputeManager(manager.SchedulerDependentManager): 'expected: %(running)s)') % locals(), context=context, instance=instance) + def bad_volumes_callback(bad_devices): + self._handle_bad_volumes_detached( + context, instance, bad_devices, block_device_info) + try: self.driver.reboot(context, instance, self._legacy_nw_info(network_info), - reboot_type, block_device_info) + reboot_type, + block_device_info=block_device_info, + bad_volumes_callback=bad_volumes_callback) except Exception, exc: LOG.error(_('Cannot reboot instance: %(exc)s'), locals(), context=context, instance=instance) |
