From e982eae40a21da26727a4d55a17a3b03f716d046 Mon Sep 17 00:00:00 2001 From: Kiran Pawar Date: Thu, 27 Jun 2024 13:33:27 +0000 Subject: [PATCH] Netapp: Retry Dedupe enable/disable if busy With some NetApp hardware models, driver turn on efficiency by default. That is why Manila might see the conflicting sis operation. Retry for 5 times, in case dedupe enable/disable failed with error "Another sis operation is currently active." Closes-bug: #2071359 Change-Id: I6229a98063d393289e2225ceacd84145ecf320d0 --- .../drivers/netapp/dataontap/client/api.py | 1 + .../netapp/dataontap/client/client_cmode.py | 38 ++++++++++++++++- .../dataontap/client/test_client_cmode.py | 42 +++++++++++++++++++ ...in-if-already-active-4625605175f76d07.yaml | 8 ++++ 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-2071359-netapp-retry-sis-operatin-if-already-active-4625605175f76d07.yaml diff --git a/manila/share/drivers/netapp/dataontap/client/api.py b/manila/share/drivers/netapp/dataontap/client/api.py index 4147d67bb1..baad849564 100644 --- a/manila/share/drivers/netapp/dataontap/client/api.py +++ b/manila/share/drivers/netapp/dataontap/client/api.py @@ -67,6 +67,7 @@ EPOLICYNOTFOUND = '18251' EEVENTNOTFOUND = '18253' ESCOPENOTFOUND = '18259' ESVMDR_CANNOT_PERFORM_OP_FOR_STATUS = '18815' +OPERATION_ALREADY_ENABLED = '40043' ENFS_V4_0_ENABLED_MIGRATION_FAILURE = '13172940' EVSERVER_MIGRATION_TO_NON_AFF_CLUSTER = '13172984' diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index 905d7e05c5..b84890f686 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -2327,16 +2327,50 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): return api_args @na_utils.trace + @manila_utils.retry(retry_param=exception.NetAppException, + interval=3, + retries=5, + backoff_rate=1) def enable_dedup(self, volume_name): """Enable deduplication on volume.""" api_args = {'path': '/vol/%s' % volume_name} - self.send_request('sis-enable', api_args) + try: + self.send_request('sis-enable', api_args) + return + except netapp_api.NaApiError as e: + enabled_msg = "has already been enabled" + if (e.code == netapp_api.OPERATION_ALREADY_ENABLED and + enabled_msg in e.message): + return + active_msg = "sis operation is currently active" + if (e.code == netapp_api.OPERATION_ALREADY_ENABLED and + active_msg in e.message): + msg = _('Unable to enable dedup. Will retry the ' + 'operation. Error details: %s') % e.message + LOG.warning(msg) + raise exception.NetAppException(msg=msg) + raise e @na_utils.trace + @manila_utils.retry(retry_param=exception.NetAppException, + interval=3, + retries=5, + backoff_rate=1) def disable_dedup(self, volume_name): """Disable deduplication on volume.""" api_args = {'path': '/vol/%s' % volume_name} - self.send_request('sis-disable', api_args) + try: + self.send_request('sis-disable', api_args) + return + except netapp_api.NaApiError as e: + active_msg = "sis operation is currently active" + if (e.code == netapp_api.OPERATION_ALREADY_ENABLED and + active_msg in e.message): + msg = _('Unable to disable dedup. Will retry the ' + 'operation. Error details: %s') % e.message + LOG.warning(msg) + raise exception.NetAppException(msg=msg) + raise e @na_utils.trace def enable_compression(self, volume_name): diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py index 5d1da06547..be40f9eda6 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py @@ -3501,6 +3501,35 @@ class NetAppClientCmodeTestCase(test.TestCase): self.client.send_request.assert_called_once_with('sis-enable', sis_enable_args) + def test_enable_dedup_already_enabled(self): + side_effect = netapp_api.NaApiError( + code=netapp_api.OPERATION_ALREADY_ENABLED, + message='It has already been enabled') + + self.mock_object(self.client, + 'send_request', + mock.Mock(side_effect=side_effect)) + + self.client.enable_dedup(fake.SHARE_NAME) + + sis_enable_args = {'path': '/vol/%s' % fake.SHARE_NAME} + + self.client.send_request.assert_called_once_with('sis-enable', + sis_enable_args) + + def test_enable_dedup_currently_active(self): + side_effect = netapp_api.NaApiError( + code=netapp_api.OPERATION_ALREADY_ENABLED, + message='The sis operation is currently active') + + self.mock_object(self.client, + 'send_request', + mock.Mock(side_effect=side_effect)) + + self.assertRaises(exception.NetAppException, + self.client.enable_dedup, + fake.SHARE_NAME) + def test_disable_dedup(self): self.mock_object(self.client, 'send_request') @@ -3512,6 +3541,19 @@ class NetAppClientCmodeTestCase(test.TestCase): self.client.send_request.assert_called_once_with('sis-disable', sis_disable_args) + def test_disable_dedup_currently_active(self): + side_effect = netapp_api.NaApiError( + code=netapp_api.OPERATION_ALREADY_ENABLED, + message='The sis operation is currently active') + + self.mock_object(self.client, + 'send_request', + mock.Mock(side_effect=side_effect)) + + self.assertRaises(exception.NetAppException, + self.client.disable_dedup, + fake.SHARE_NAME) + def test_enable_compression(self): self.mock_object(self.client, 'send_request') diff --git a/releasenotes/notes/bug-2071359-netapp-retry-sis-operatin-if-already-active-4625605175f76d07.yaml b/releasenotes/notes/bug-2071359-netapp-retry-sis-operatin-if-already-active-4625605175f76d07.yaml new file mode 100644 index 0000000000..5e60af5515 --- /dev/null +++ b/releasenotes/notes/bug-2071359-netapp-retry-sis-operatin-if-already-active-4625605175f76d07.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + NetApp ONTAP driver will now retry the sis operation (e.g. dedupe) if sis + operation is currently active. This is needed because NetApp turns on + efficiency (by default) on latest hardware which causes conflicting sis + operation when Manila tries to turn it off. For more details, please check + Launchpad `bug #2071359 `_