Browse Source

Fix _per_gb_min usage with _per_gb

As _per_gb_min was a text, it was in many cases larger, than
_per_gb value. So, situations, when big drives were attached
with min iops are now excluded.

Change-Id: Ie24e5a85b54e4734c9b96987cc8ec497aa0ac435
changes/70/624970/5
Dmitriy Rabotjagov 3 years ago
parent
commit
b9b260a0a8
  1. 16
      cinder/tests/unit/volume/test_connection.py
  2. 2
      cinder/volume/manager.py

16
cinder/tests/unit/volume/test_connection.py

@ -192,7 +192,7 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
qos_values = {'consumer': 'front-end',
'specs': {
'write_iops_sec_per_gb': 5,
'write_iops_sec_per_gb': 30,
'read_iops_sec_per_gb': 7700,
'total_iops_sec_per_gb': 300000,
'read_bytes_sec_per_gb': 10,
@ -207,7 +207,7 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
type_qos.return_value = dict(qos_specs=qos_values)
driver_init.return_value = {'data': {}}
mock_get_target.return_value = None
qos_specs_expected = {'write_iops_sec': 15,
qos_specs_expected = {'write_iops_sec': 90,
'read_iops_sec': 23100,
'total_iops_sec': 900000,
'read_bytes_sec': 30,
@ -253,8 +253,8 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
qos_values = {'consumer': 'front-end',
'specs': {
'write_iops_sec_per_gb_min': 15,
'write_iops_sec_per_gb': 5,
'write_iops_sec_per_gb_min': 800,
'write_iops_sec_per_gb': 30,
'read_iops_sec_per_gb_min': 23100,
'read_iops_sec_per_gb': 7700,
'total_iops_sec_per_gb_min': 900000,
@ -274,7 +274,7 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
type_qos.return_value = dict(qos_specs=qos_values)
driver_init.return_value = {'data': {}}
mock_get_target.return_value = None
qos_specs_expected = {'write_iops_sec': 15,
qos_specs_expected = {'write_iops_sec': 800,
'read_iops_sec': 23100,
'total_iops_sec': 900000,
'read_bytes_sec': 30,
@ -320,8 +320,8 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
qos_values = {'consumer': 'front-end',
'specs': {
'write_iops_sec_per_gb_min': 15,
'write_iops_sec_per_gb': 5,
'write_iops_sec_per_gb_min': 800,
'write_iops_sec_per_gb': 30,
'read_iops_sec_per_gb_min': 23100,
'read_iops_sec_per_gb': 7700,
'total_iops_sec_per_gb_min': 900000,
@ -341,7 +341,7 @@ class VolumeConnectionTestCase(base.BaseVolumeTestCase):
type_qos.return_value = dict(qos_specs=qos_values)
driver_init.return_value = {'data': {}}
mock_get_target.return_value = None
qos_specs_expected = {'write_iops_sec': 500,
qos_specs_expected = {'write_iops_sec': 3000,
'read_iops_sec': 770000,
'total_iops_sec': 30000000,
'read_bytes_sec': 1000,

2
cinder/volume/manager.py

@ -1620,7 +1620,7 @@ class VolumeManager(manager.CleanableManager,
option_per_gb = '%s_per_gb' % option
option_per_gb_min = '%s_per_gb_min' % option
if option_per_gb in specs:
minimum_value = specs.pop(option_per_gb_min, 0)
minimum_value = int(specs.pop(option_per_gb_min, 0))
value = int(specs[option_per_gb]) * volume_size
specs[option] = max(minimum_value, value)
specs.pop(option_per_gb)

Loading…
Cancel
Save