Browse Source

API validation: Add cinder_host type to support ipv6 in manage

This will fail due to overly restrictive regex validation:
  cinder manage hostgroup@cloud#[dead:beef::cafe]:/cinder01 abcd

This is because validation for this call checks for a valid
hostname but needs to check for any string that would be a valid
"host" in Cinder, which is not the same thing.

Closes-Bug: #1904892
Change-Id: I1349e8d3eb422f9dcd533c54f922f7ab8133b753
(cherry picked from commit 8687925ce7)
(cherry picked from commit 51b92e9fa6)
changes/04/783204/1
Eric Harney 9 months ago
parent
commit
d5fed21fdf
  1. 2
      cinder/api/schemas/volume_manage.py
  2. 12
      cinder/api/validation/parameter_types.py
  3. 3
      cinder/tests/unit/api/contrib/test_volume_manage.py
  4. 7
      releasenotes/notes/bug-1904892-ipv6-nfs-manage-391118115dfaaf54.yaml

2
cinder/api/schemas/volume_manage.py

@ -33,7 +33,7 @@ volume_manage_create = {
"bootable": parameter_types.boolean,
"volume_type": parameter_types.name_allow_zero_min_length,
"name": parameter_types.name_allow_zero_min_length,
"host": parameter_types.hostname,
"host": parameter_types.cinder_host,
"ref": {'type': ['object', 'string']},
"metadata": parameter_types.metadata_allows_null,
},

12
cinder/api/validation/parameter_types.py

@ -232,6 +232,18 @@ hostname = {
'pattern': '^[a-zA-Z0-9-._#@:/+]*$'
}
cinder_host = {
# A string that represents a cinder host.
# Examples:
# hostname
# hostname.domain
# hostname.domain@backend
# hostname.domain@backend#pool
# hostname.domain@backend#[dead:beef::cafe]:/complex_ipv6_pool_w_share
'type': ['string', 'null'], 'minLength': 1, 'maxLength': 255,
'pattern': r'^[a-zA-Z0-9-._#@:/+\[\]]*$' # hostname plus brackets
}
resource_type = {'type': ['string', 'null'], 'minLength': 0, 'maxLength': 40}

3
cinder/tests/unit/api/contrib/test_volume_manage.py

@ -205,7 +205,8 @@ class VolumeManageTest(test.TestCase):
@ddt.data({'host': 'host_ok'},
{'host': 'user@host#backend:/vol_path'},
{'host': 'host@backend#parts+of+pool'})
{'host': 'host@backend#parts+of+pool'},
{'host': 'host@backend#[dead:beef::cafe]:/vol01'})
@ddt.unpack
@mock.patch('cinder.volume.api.API.manage_existing', wraps=api_manage)
def test_manage_volume_ok(self, mock_api_manage, host):

7
releasenotes/notes/bug-1904892-ipv6-nfs-manage-391118115dfaaf54.yaml

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug #1904892 <https://bugs.launchpad.net/cinder/+bug/1904892>`_:
Fix cinder manage operations for NFS backends using IPv6 addresses
in the NFS server address. These were previously rejected by the
Cinder API.
Loading…
Cancel
Save