When any vm creation fails because of exceeding 'gigabytes',
'volumes', 'per_volume_gigabytes' quotas, the error message
generated is specific to 'volumes' quota which says
"Volume resource quota exceeded". Instead, the error message
should be specific to the quota which failed.
Change-Id: I9c1ac2cd4752d5aac20d06407792647b4549ad3d
Closes-Bug:
1680457
(cherry picked from commit
510371d526bd45195be806fb153646abdc269b70)
self._block_device_info_to_legacy(block_device_info)
return block_device_info
- except exception.OverQuota:
- msg = _LW('Failed to create block device for instance due to '
- 'being over volume resource quota')
- LOG.warning(msg, instance=instance)
- raise exception.VolumeLimitExceeded()
+ except exception.OverQuota as e:
+ LOG.warning(_LW('Failed to create block device for instance due'
+ ' to exceeding volume related resource quota.'
+ ' Error: %s'), e.message, instance=instance)
+ raise
except Exception:
LOG.exception(_LE('Instance failed block device setup'),
if network_info is not None:
network_info.wait(do_raise=False)
except (exception.UnexpectedTaskStateError,
- exception.VolumeLimitExceeded,
- exception.InvalidBDM) as e:
+ exception.OverQuota, exception.InvalidBDM) as e:
# Make sure the async call finishes
if network_info is not None:
network_info.wait(do_raise=False)
self.api = api_fixture.api
@mock.patch('nova.volume.cinder.cinderclient')
- def test_over_limit_volumes(self, mock_cinder):
- """Regression test for bug #1554631.
+ def test_over_limit_volumes_with_message(self, mock_cinder):
+ """Regression test for bug #1680457.
When the Cinder client returns OverLimit when trying to create
- a volume, an OverQuota exception should be raised with the value being
- volumes.
+ a volume, an OverQuota exception should be raised.
"""
cinder_client = mock.Mock()
mock_cinder.return_value = cinder_client
- exc = cinder_exceptions.OverLimit(413)
+ msg = ("VolumeSizeExceedsLimit: Requested volume size XG is larger"
+ " than maximum allowed limit YG.")
+ exc = cinder_exceptions.OverLimit(413, message=msg)
cinder_client.volumes.create.side_effect = exc
volume = {'display_name': 'vol1', 'size': 3}
self.api.post_volume, {'volume': volume})
self.assertEqual(403, e.response.status_code)
# Make sure we went over on volumes
- self.assertIn('volumes', e.response.text)
+ self.assertIn('VolumeSizeExceedsLimit', e.response.text)
@mock.patch('nova.volume.cinder.cinderclient')
def test_over_limit_snapshots(self, mock_cinder):
self.instance_object, 'fake_id', 'fake_id2', {})
@mock.patch.object(cinder.API, 'create',
- side_effect=exception.OverQuota(overs='volumes'))
+ side_effect=exception.OverQuota(overs='something'))
def test_prep_block_device_over_quota_failure(self, mock_create):
instance = self._create_fake_instance_obj()
bdms = [
})]
bdms = block_device_obj.block_device_make_list_from_dicts(
self.context, bdms)
- self.assertRaises(exception.VolumeLimitExceeded,
+ self.assertRaises(exception.OverQuota,
compute_manager.ComputeManager()._prep_block_device,
self.context, instance, bdms)
self.assertTrue(mock_create.called)
res = method(self, ctx, volume_id, *args, **kwargs)
except (keystone_exception.NotFound, cinder_exception.NotFound):
_reraise(exception.VolumeNotFound(volume_id=volume_id))
- except cinder_exception.OverLimit:
- _reraise(exception.OverQuota(overs='volumes'))
+ except cinder_exception.OverLimit as e:
+ _reraise(exception.OverQuota(message=e.message))
return res
return translate_cinder_exception(wrapper)