Add extend/shrink feature for glusterfs directory layout

- Implements extend/shrink feature for glusterfs directory layout backend
- Update share_back_ends_feature_support_mapping.rst
- Add a release note

Depends-On: https://review.opendev.org/#/c/673771/
Change-Id: I37b315ec61e81e8ce6f4b72bc03e887cc145464d
Implements: bp glusterfs-direcotry-layout-extend-shrink-share
This commit is contained in:
Woohyung Han 2019-08-06 07:01:18 +00:00
parent 0ebd368b44
commit b917fabf14
4 changed files with 191 additions and 74 deletions

View File

@ -30,69 +30,69 @@ Column value "-" means that this feature is not currently supported.
Mapping of share drivers and share features support
---------------------------------------------------
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Driver name | create delete share | manage unmanage share | extend share | shrink share | create delete snapshot | create share from snapshot | manage unmanage snapshot | revert to snapshot | mountable snapshot |
+========================================+=======================+=======================+==============+==============+========================+============================+==========================+====================+====================+
| ZFSonLinux | M | N | M | M | M | M | N | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Container | N | \- | N | \- | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Generic (Cinder as back-end) | J | K | L | L | J | J | M | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NetApp Clustered Data ONTAP | J | L | L | L | J | J | N | O | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC VMAX | O | \- | O | \- | O | O | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC VNX | J | \- | \- | \- | J | J | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Unity | N | \- | N | S | N | N | \- | S | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Isilon | K | \- | M | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| GlusterFS | J | \- | \- | \- | volume layout (L) | volume layout (L) | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| GlusterFS-Native | J | \- | \- | \- | K | L | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| HDFS | K | \- | M | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Hitachi HNAS | L | L | L | M | L | L | O | O | O |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Hitachi HSP | N | N | N | N | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| HPE 3PAR | K | \- | \- | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Huawei | K | L | L | L | K | M | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| IBM GPFS | K | O | L | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INFINIDAT | Q | \- | Q | \- | Q | Q | \- | Q | Q |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INSPUR AS13000 | R | \- | R | \- | R | R | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INSPUR InStorage | T | \- | T | \- | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Infortrend | T | T | T | T | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| LVM | M | \- | M | \- | M | M | \- | O | O |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Quobyte | K | \- | M | M | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Windows SMB | L | L | L | L | L | L | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Oracle ZFSSA | K | N | M | M | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| CephFS | M | \- | M | M | M | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Tegile | M | \- | M | M | M | M | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NexentaStor4 | N | \- | N | \- | N | N | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NexentaStor5 | N | \- | N | N | N | N | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| MapRFS | O | O | O | O | O | O | O | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| QNAP | O | O | O | \- | O | O | O | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------+--------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Driver name | create delete share | manage unmanage share | extend share | shrink share | create delete snapshot | create share from snapshot | manage unmanage snapshot | revert to snapshot | mountable snapshot |
+========================================+=======================+=======================+==========================+==========================+========================+============================+==========================+====================+====================+
| ZFSonLinux | M | N | M | M | M | M | N | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Container | N | \- | N | \- | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Generic (Cinder as back-end) | J | K | L | L | J | J | M | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NetApp Clustered Data ONTAP | J | L | L | L | J | J | N | O | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC VMAX | O | \- | O | \- | O | O | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC VNX | J | \- | \- | \- | J | J | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Unity | N | \- | N | S | N | N | \- | S | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| EMC Isilon | K | \- | M | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| GlusterFS | J | \- | directory layout (T) | directory layout (T) | volume layout (L) | volume layout (L) | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| GlusterFS-Native | J | \- | \- | \- | K | L | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| HDFS | K | \- | M | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Hitachi HNAS | L | L | L | M | L | L | O | O | O |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Hitachi HSP | N | N | N | N | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| HPE 3PAR | K | \- | \- | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Huawei | K | L | L | L | K | M | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| IBM GPFS | K | O | L | \- | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INFINIDAT | Q | \- | Q | \- | Q | Q | \- | Q | Q |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INSPUR AS13000 | R | \- | R | \- | R | R | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| INSPUR InStorage | T | \- | T | \- | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Infortrend | T | T | T | T | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| LVM | M | \- | M | \- | M | M | \- | O | O |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Quobyte | K | \- | M | M | \- | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Windows SMB | L | L | L | L | L | L | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Oracle ZFSSA | K | N | M | M | K | K | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| CephFS | M | \- | M | M | M | \- | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| Tegile | M | \- | M | M | M | M | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NexentaStor4 | N | \- | N | \- | N | N | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| NexentaStor5 | N | \- | N | N | N | N | \- | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| MapRFS | O | O | O | O | O | O | O | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
| QNAP | O | O | O | \- | O | O | O | \- | \- |
+----------------------------------------+-----------------------+-----------------------+--------------------------+--------------------------+------------------------+----------------------------+--------------------------+--------------------+--------------------+
Mapping of share drivers and share access rules support
-------------------------------------------------------

View File

@ -15,16 +15,19 @@
"""GlusterFS directory mapped share layout."""
import math
import os
from oslo_config import cfg
from oslo_log import log
import six
import xml.etree.cElementTree as etree
from manila import exception
from manila.i18n import _
from manila.share.drivers.glusterfs import common
from manila.share.drivers.glusterfs import layout
from manila import utils
LOG = log.getLogger(__name__)
@ -137,16 +140,12 @@ class GlusterfsDirectoryMappedLayout(layout.GlusterfsShareLayoutBase):
"""Create a sub-directory/share in the GlusterFS volume."""
# probe into getting a NAS protocol helper for the share in order
# to facilitate early detection of unsupported protocol type
sizestr = six.text_type(share['size']) + 'GB'
share_dir = '/' + share['name']
local_share_path = self._get_local_share_path(share)
cmd = ['mkdir', local_share_path]
# set hard limit quota on the sub-directory/share
args = ('volume', 'quota', self.gluster_manager.volume,
'limit-usage', share_dir, sizestr)
try:
self.driver._execute(*cmd, run_as_root=True)
self.gluster_manager.gluster_call(*args)
self._set_directory_quota(share, share['size'])
except Exception as exc:
if isinstance(exc, exception.ProcessExecutionError):
exc = exception.GlusterfsException(exc)
@ -205,7 +204,46 @@ class GlusterfsDirectoryMappedLayout(layout.GlusterfsShareLayoutBase):
raise NotImplementedError
def extend_share(self, share, new_size, share_server=None):
raise NotImplementedError
"""Extend a sub-directory/share in the GlusterFS volume."""
self._set_directory_quota(share, new_size)
def shrink_share(self, share, new_size, share_server=None):
raise NotImplementedError
"""Shrink a sub-directory/share in the GlusterFS volume."""
usage = self._get_directory_usage(share)
consumed_limit = int(math.ceil(usage))
if consumed_limit > new_size:
raise exception.ShareShrinkingPossibleDataLoss(
share_id=share['id'])
self._set_directory_quota(share, new_size)
def _set_directory_quota(self, share, new_size):
sizestr = six.text_type(new_size) + 'GB'
share_dir = '/' + share['name']
args = ('volume', 'quota', self.gluster_manager.volume,
'limit-usage', share_dir, sizestr)
try:
self.gluster_manager.gluster_call(*args)
except exception.GlusterfsException:
LOG.error('Unable to set quota share %s', share['name'])
raise
def _get_directory_usage(self, share):
share_dir = '/' + share['name']
args = ('--xml', 'volume', 'quota', self.gluster_manager.volume,
'list', share_dir)
try:
out, err = self.gluster_manager.gluster_call(*args)
except exception.GlusterfsException:
LOG.error('Unable to get quota share %s', share['name'])
raise
volxml = etree.fromstring(out)
usage_byte = volxml.find('./volQuota/limit/used_space').text
usage = utils.translate_string_size_to_float(usage_byte)
return usage

View File

@ -378,15 +378,91 @@ class GlusterfsDirectoryMappedLayoutTestCase(test.TestCase):
def test_ensure_share(self):
self.assertIsNone(self._layout.ensure_share(self._context, self.share))
def test_extend_share(self):
self._layout.extend_share(self.share, 3)
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'volume', 'quota', 'testvol', 'limit-usage', '/fakename', '3GB')
def test_shrink_share(self):
self.mock_object(self._layout, '_get_directory_usage',
mock.Mock(return_value=10.0))
self._layout.shrink_share(self.share, 11)
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'volume', 'quota', 'testvol', 'limit-usage', '/fakename', '11GB')
def test_shrink_share_data_loss(self):
self.mock_object(self._layout, '_get_directory_usage',
mock.Mock(return_value=10.0))
shrink_on_gluster = self.mock_object(self._layout,
'_set_directory_quota')
self.assertRaises(exception.ShareShrinkingPossibleDataLoss,
self._layout.shrink_share, self.share, 9)
shrink_on_gluster.assert_not_called()
def test_set_directory_quota(self):
self._layout._set_directory_quota(self.share, 3)
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'volume', 'quota', 'testvol', 'limit-usage', '/fakename', '3GB')
def test_set_directory_quota_unable_to_set(self):
self.mock_object(self._layout.gluster_manager, 'gluster_call',
mock.Mock(side_effect=exception.GlusterfsException))
self.assertRaises(exception.GlusterfsException,
self._layout._set_directory_quota, self.share, 3)
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'volume', 'quota', 'testvol', 'limit-usage', '/fakename', '3GB')
def test_get_directory_usage(self):
def xml_output(*ignore_args, **ignore_kwargs):
return """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
<opRet>0</opRet>
<opErrno>0</opErrno>
<opErrstr/>
<volQuota>
<limit>
<used_space>10737418240</used_space>
</limit>
</volQuota>
</cliOutput>""", ''
self.mock_object(self._layout.gluster_manager, 'gluster_call',
mock.Mock(side_effect=xml_output))
ret = self._layout._get_directory_usage(self.share)
self.assertEqual(10.0, ret)
share_dir = '/' + self.share['name']
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'--xml', 'volume', 'quota', self._layout.gluster_manager.volume,
'list', share_dir)
def test_get_directory_usage_unable_to_get(self):
self.mock_object(self._layout.gluster_manager, 'gluster_call',
mock.Mock(side_effect=exception.GlusterfsException))
self.assertRaises(exception.GlusterfsException,
self._layout._get_directory_usage, self.share)
share_dir = '/' + self.share['name']
self._layout.gluster_manager.gluster_call.assert_called_once_with(
'--xml', 'volume', 'quota', self._layout.gluster_manager.volume,
'list', share_dir)
@ddt.data(
('create_share_from_snapshot', ('context', 'share', 'snapshot'),
{'share_server': None}),
('create_snapshot', ('context', 'snapshot'), {'share_server': None}),
('delete_snapshot', ('context', 'snapshot'), {'share_server': None}),
('manage_existing', ('share', 'driver_options'), {}),
('unmanage', ('share',), {}),
('extend_share', ('share', 'new_size'), {'share_server': None}),
('shrink_share', ('share', 'new_size'), {'share_server': None}))
('unmanage', ('share',), {}))
def test_nonimplemented_methods(self, method_invocation):
method, args, kwargs = method_invocation
self.assertRaises(NotImplementedError, getattr(self._layout, method),

View File

@ -0,0 +1,3 @@
---
features:
- For glusterfs_nfs driver, added share extend/shrink support.