Skip to content

Commit d82740d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "compute: Don't detach volumes when RescheduledException raised without retry" into stable/victoria
2 parents e71a6fa + eda4588 commit d82740d

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

nova/compute/manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,8 +2230,6 @@ def _do_build_and_run_instance(self, context, instance, image,
22302230
instance=instance)
22312231
self._cleanup_allocated_networks(context, instance,
22322232
requested_networks)
2233-
self._cleanup_volumes(context, instance,
2234-
block_device_mapping, raise_exc=False)
22352233
compute_utils.add_instance_fault_from_exc(context,
22362234
instance, e, sys.exc_info(),
22372235
fault_message=e.kwargs['reason'])

nova/tests/functional/regressions/test_bug_1899649.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,9 @@ def test_failure_to_schedule_with_host(self):
9292
self._assert_failure_and_volume_attachments(server)
9393

9494
def test_failure_to_build_with_az_and_host(self):
95-
# Assert that a volume attachments does not remain after a failure to
95+
# Assert that a volume attachments remain after a failure to
9696
# build and reschedule by providing an availability_zone *and* host,
9797
# skipping the scheduler. This is bug #1899649.
9898
self.server['availability_zone'] = 'nova:compute1'
9999
server = self.admin_api.post_server({'server': self.server})
100-
101-
# Assert the server ends up in an ERROR state
102-
self._wait_for_state_change(server, 'ERROR')
103-
104-
# FIXME(lyarwood): A single volume attachment should be present for the
105-
# instance at this stage as the volume *can* otherwise be marked as
106-
# available within Cinder if it isn't multi-attached.
107-
attachments = self.cinder.volume_to_attachment.get(self.volume_id)
108-
self.assertEqual(0, len(attachments))
109-
self.assertNotIn(
110-
self.volume_id, self.cinder.volume_ids_for_instance(server['id']))
100+
self._assert_failure_and_volume_attachments(server)

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6876,14 +6876,13 @@ def test_rescheduled_exception_with_sriov_network_allocated(self,
68766876
@mock.patch.object(objects.Instance, 'save')
68776877
@mock.patch.object(manager.ComputeManager,
68786878
'_nil_out_instance_obj_host_and_node')
6879-
@mock.patch.object(manager.ComputeManager, '_cleanup_volumes')
68806879
@mock.patch.object(manager.ComputeManager, '_cleanup_allocated_networks')
68816880
@mock.patch.object(manager.ComputeManager, '_set_instance_obj_error_state')
68826881
@mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
68836882
@mock.patch.object(manager.ComputeManager, '_build_and_run_instance')
68846883
def test_rescheduled_exception_without_retry(self,
6885-
mock_build_run, mock_add, mock_set, mock_clean_net, mock_clean_vol,
6886-
mock_nil, mock_save, mock_start, mock_finish):
6884+
mock_build_run, mock_add, mock_set, mock_clean_net, mock_nil,
6885+
mock_save, mock_start, mock_finish):
68876886
self._do_build_instance_update(mock_save)
68886887
mock_build_run.side_effect = exception.RescheduledException(reason='',
68896888
instance_uuid=self.instance.uuid)
@@ -6919,9 +6918,6 @@ def _wrapped_do_build_and_run_instance(*args, **kwargs):
69196918
self.accel_uuids)
69206919
mock_clean_net.assert_called_once_with(self.context, self.instance,
69216920
self.requested_networks)
6922-
mock_clean_vol.assert_called_once_with(self.context,
6923-
self.instance, self.block_device_mapping,
6924-
raise_exc=False)
69256921
mock_add.assert_called_once_with(self.context, self.instance,
69266922
mock.ANY, mock.ANY, fault_message=mock.ANY)
69276923
mock_nil.assert_called_once_with(self.instance)

0 commit comments

Comments
 (0)