Prevent boot if ephemeral disk size > flavor value
Nova allows following command nova boot --image 3ec2603b-9113-4ca1-92cf-690e573985bd --flavor 11 --block-device source=blank,dest=local --block-device source=blank,dest=local test which in turn translate the ephemeral disk mappings into 2 default ephemeral disk and makes the total spanwed ephemeral disk size greater than flavor ephemeral disk. This patch add checks to this kind of situation and prevents it. Change-Id: I1952eeb04bf3835182e575e418632a6d611c84e9 Closes-Bug: 1483645
This commit is contained in:
parent
d669fc8368
commit
c7de85445a
@ -1309,7 +1309,7 @@ class API(base.Base):
|
||||
"(source: 'blank', dest: 'volume') need to have non-zero "
|
||||
"size"))
|
||||
|
||||
ephemeral_size = sum(bdm.volume_size or 0
|
||||
ephemeral_size = sum(bdm.volume_size or instance_type['ephemeral_gb']
|
||||
for bdm in block_device_mappings
|
||||
if block_device.new_format_is_ephemeral(bdm))
|
||||
if ephemeral_size > instance_type['ephemeral_gb']:
|
||||
|
@ -263,7 +263,9 @@ class InvalidBDMLocalsLimit(InvalidBDM):
|
||||
|
||||
class InvalidBDMEphemeralSize(InvalidBDM):
|
||||
msg_fmt = _("Ephemeral disks requested are larger than "
|
||||
"the instance type allows.")
|
||||
"the instance type allows. If no size is given "
|
||||
"in one block device mapping, flavor ephemeral "
|
||||
"size will be used.")
|
||||
|
||||
|
||||
class InvalidBDMSwapSize(InvalidBDM):
|
||||
|
@ -1057,6 +1057,40 @@ class ComputeVolumeTestCase(BaseTestCase):
|
||||
self.context, instance, instance_type,
|
||||
mappings_)
|
||||
|
||||
def test_validate_bdm_with_more_than_one_default(self):
|
||||
instance_type = {'swap': 1, 'ephemeral_gb': 1}
|
||||
all_mappings = [fake_block_device.FakeDbBlockDeviceDict({
|
||||
'id': 1,
|
||||
'no_device': None,
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
'snapshot_id': None,
|
||||
'volume_size': 1,
|
||||
'device_name': 'vda',
|
||||
'boot_index': 0,
|
||||
'delete_on_termination': False}, anon=True),
|
||||
fake_block_device.FakeDbBlockDeviceDict({
|
||||
'device_name': '/dev/vdb',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
'device_type': 'disk',
|
||||
'volume_size': None,
|
||||
'boot_index': -1}, anon=True),
|
||||
fake_block_device.FakeDbBlockDeviceDict({
|
||||
'device_name': '/dev/vdc',
|
||||
'source_type': 'blank',
|
||||
'destination_type': 'local',
|
||||
'device_type': 'disk',
|
||||
'volume_size': None,
|
||||
'boot_index': -1}, anon=True)]
|
||||
all_mappings = block_device_obj.block_device_make_list_from_dicts(
|
||||
self.context, all_mappings)
|
||||
|
||||
self.assertRaises(exception.InvalidBDMEphemeralSize,
|
||||
self.compute_api._validate_bdm,
|
||||
self.context, self.instance,
|
||||
instance_type, all_mappings)
|
||||
|
||||
def test_validate_bdm_media_service_exceptions(self):
|
||||
instance_type = {'swap': 1, 'ephemeral_gb': 1}
|
||||
bdms = [fake_block_device.FakeDbBlockDeviceDict({
|
||||
|
Loading…
x
Reference in New Issue
Block a user