Browse Source

[NetApp] Fix share shrink error status

This patch fixes the error raised by NetApp driver when the user try
to shrink a share to a size smaller than the current used space. Now
the driver raises "shrinking_possible_data_loss" instead of
"shrinking_error".

Change-Id: I01a549a0e299ae0d0d9b603a9d0797f16f4b68b3
Closes-Bug: #1858328
(cherry picked from commit c169902d41)
(cherry picked from commit 97a9132098)
(cherry picked from commit d7853ae6ed)
changes/42/724342/1
danielarthurt 4 months ago
committed by Douglas Viroel
parent
commit
421cd52014
4 changed files with 50 additions and 3 deletions
  1. +1
    -0
      manila/share/drivers/netapp/dataontap/client/api.py
  2. +15
    -3
      manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py
  3. +27
    -0
      manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py
  4. +7
    -0
      releasenotes/notes/bug-1858328-netapp-fix-shrinking-error-48bcfffe694f5e81.yaml

+ 1
- 0
manila/share/drivers/netapp/dataontap/client/api.py View File

@@ -33,6 +33,7 @@ from manila.share.drivers.netapp import utils
LOG = log.getLogger(__name__)

EONTAPI_EINVAL = '22'
EVOLOPNOTSUPP = '160'
EAPIERROR = '13001'
EAPINOTFOUND = '13005'
ESNAPSHOTNOTALLOWED = '13023'


+ 15
- 3
manila/share/drivers/netapp/dataontap/cluster_mode/lib_base.py View File

@@ -1371,9 +1371,21 @@ class NetAppCmodeFileStorageLibrary(object):
filesys_size_fixed=False)
LOG.debug('Shrinking share %(name)s to %(size)s GB.',
{'name': share_name, 'size': new_size})
vserver_client.set_volume_size(share_name, new_size)
self._adjust_qos_policy_with_volume_resize(share, new_size,
vserver_client)

try:
vserver_client.set_volume_size(share_name, new_size)
except netapp_api.NaApiError as e:
if e.code == netapp_api.EVOLOPNOTSUPP:
msg = _('Failed to shrink share %(share_id)s. '
'The current used space is larger than the the size'
' requested.')
msg_args = {'share_id': share['id']}
LOG.error(msg, msg_args)
raise exception.ShareShrinkingPossibleDataLoss(
share_id=share['id'])

self._adjust_qos_policy_with_volume_resize(
share, new_size, vserver_client)

@na_utils.trace
def update_access(self, context, share, access_rules, add_rules,


+ 27
- 0
manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_lib_base.py View File

@@ -97,6 +97,10 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
mock.Mock(return_value=self.mock_dm_session))
self.mock_object(data_motion, 'get_client_for_backend')

def _mock_api_error(self, code='fake', message='fake'):
return mock.Mock(side_effect=netapp_api.NaApiError(code=code,
message=message))

def test_init(self):
self.assertEqual(fake.DRIVER_NAME, self.library.driver_name)
self.assertEqual(1, na_utils.validate_driver_instantiation.call_count)
@@ -2256,6 +2260,29 @@ class NetAppFileStorageLibraryTestCase(test.TestCase):
mock_adjust_qos_policy.assert_called_once_with(
fake.SHARE, new_size, vserver_client)

def test_shrinking_possible_data_loss(self):

naapi_error = self._mock_api_error(code=netapp_api.EVOLOPNOTSUPP,
message='Possible data loss')

vserver_client = mock.Mock()
self.mock_object(self.library,
'_get_vserver',
mock.Mock(return_value=(fake.VSERVER1,
vserver_client)))

mock_set_volume_size = self.mock_object(
vserver_client, 'set_volume_size', naapi_error)

new_size = fake.SHARE['size'] - 1

self.assertRaises(exception.ShareShrinkingPossibleDataLoss,
self.library.shrink_share,
fake.SHARE, new_size)

self.library._get_vserver.assert_called_once_with(share_server=None)
mock_set_volume_size.assert_called_once_with(fake.SHARE_NAME, new_size)

def test_update_access(self):

vserver_client = mock.Mock()


+ 7
- 0
releasenotes/notes/bug-1858328-netapp-fix-shrinking-error-48bcfffe694f5e81.yaml View File

@@ -0,0 +1,7 @@
---
fixes:
- |
Fixed an issue in NetApp driver when shrinking shares to a size
smaller than the current used space. Now it will return a more
appropriate error status called
``shrinking_possible_data_loss_error``.

Loading…
Cancel
Save