HPE 3PAR: Fix to use small QoS Latency value

If QoS Latency is created with small value (less than 1; eg 0.1),
then during create volume, below error occurs:

Exception: invalid literal for int() with base 10: '0.1'

This patch is submitted to handle small QoS Latency values.

Closes-Bug: #2018994
Change-Id: I09cc3986a7be614f8870f3712eb05b5adfed2425
This commit is contained in:
raghavendrat 2023-05-09 12:06:52 +00:00
parent 9e25452102
commit 5546b13597
3 changed files with 28 additions and 4 deletions

View File

@ -1107,19 +1107,26 @@ class TestHPE3PARDriverBase(HPE3PARBaseDriver):
self.assertEqual(expected_cpg, result['snap_cpg'])
# (i) normal value; eg. 7, 10, etc
# (ii) small value less than 1; eg. 0.1, 0.02, etc
@ddt.data({'latency': 25}, {'latency': 0.2})
@ddt.unpack
@mock.patch.object(volume_types, 'get_volume_type')
def test_create_volume_qos(self, _mock_volume_types):
def test_create_volume_qos(self, _mock_volume_types, latency):
# setup_mock_client drive with default configuration
# and return the mock HTTP 3PAR client
mock_client = self.setup_driver()
QOS = self.QOS.copy()
QOS['qos:latency'] = latency
_mock_volume_types.return_value = {
'name': 'gold',
'extra_specs': {
'cpg': HPE3PAR_CPG_QOS,
'snap_cpg': HPE3PAR_CPG_SNAP,
'vvs_name': self.VVS_NAME,
'qos': self.QOS,
'qos': QOS,
'tpvv': True,
'tdvv': False,
'volume_type': self.volume_type}}

View File

@ -304,11 +304,12 @@ class HPE3PARCommon(object):
4.0.18 - During conversion of volume to base volume,
error out if it has child snapshot(s). Bug #1994521
4.0.19 - Update code to work with new WSAPI (of 2023). Bug #2015746
4.0.20 - Use small QoS Latency value. Bug #2018994
"""
VERSION = "4.0.19"
VERSION = "4.0.20"
stats = {}
@ -2051,7 +2052,17 @@ class HPE3PARCommon(object):
if min_bw is None:
qosRule['bwMinGoalKB'] = int(max_bw) * units.Ki
if latency:
# latency could be values like 2, 5, etc or
# small values like 0.1, 0.02, etc.
# we are converting to float so that 0.1 doesn't become 0
latency = float(latency)
if latency >= 1:
# by default, latency in millisecs
qosRule['latencyGoal'] = int(latency)
else:
# latency < 1 Eg. 0.1, 0.02, etc
# convert latency to microsecs
qosRule['latencyGoaluSecs'] = int(latency * 1000)
if priority:
qosRule['priority'] = self.qos_priority_level.get(priority.lower())

View File

@ -0,0 +1,6 @@
---
fixes:
- |
HPE 3PAR driver `bug #2018994
<https://bugs.launchpad.net/cinder/+bug/2018994>`_:
Fixed: use small QoS Latency value (less than 1)