Skip to content

Commit 2f0b270

Browse files
committed
fix(cinder-understack): remove incorrect calls causing a crash
Remove these incorrect calls which result in a crash when a library instance is cleaned up. Update the tests to ensure this does not happen again.
1 parent 77c88a0 commit 2f0b270

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

python/cinder-understack/cinder_understack/dynamic_netapp_driver.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,8 @@ def _remove_svm_lib(self, svm_name: str, svm_lib: NetAppMinimalLibrary):
238238
# TODO: Need to free up resources here.
239239
LOG.info("Removing resources for SVM library %s", svm_name)
240240
# Stop any looping calls if they exist
241-
if svm_lib._looping_call and hasattr(svm_lib, "loopingcalls"):
241+
if hasattr(svm_lib, "loopingcalls"):
242242
LOG.info("Stopping looping call for SVM library %s", svm_name)
243-
svm_lib.loopingcalls.stop_tasks()
244-
# Adding None coz it has a reference to the looping call
245-
svm_lib.looping_call = None
246-
# There are other attributes which are in svm_lib even after
247-
# Stopping the looping.
248243

249244
def _refresh_svm_libraries(self):
250245
return self._actual_refresh_svm_libraries(context.get_admin_context())

python/cinder-understack/cinder_understack/tests/test_dynamic_netapp_driver.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010
from cinder.tests.unit import utils as test_utils
1111
from cinder.tests.unit.volume.drivers.netapp import fakes as na_fakes
1212
from cinder.volume.drivers.netapp.dataontap.nvme_library import NetAppNVMeStorageLibrary
13+
from cinder.volume.drivers.netapp.dataontap.utils import loopingcalls
1314

1415
from cinder_understack import dynamic_netapp_driver
1516

1617

18+
def _create_mock_svm_lib(svm_name: str):
19+
mock_lib = mock.create_autospec(
20+
dynamic_netapp_driver.NetAppMinimalLibrary, instance=True
21+
)
22+
mock_lib.vserver = svm_name
23+
mock_lib.loopingcalls = loopingcalls.LoopingCalls()
24+
return mock_lib
25+
26+
1727
class NetappDynamicDriverTestCase(test.TestCase):
1828
"""Test case for NetappCinderDynamicDriver."""
1929

@@ -152,21 +162,16 @@ def test_refresh_svm_libraries_adds_and_removes_svms(
152162
expected_svm = f"os-{self.project_id}"
153163

154164
self.driver._libraries = {
155-
"os-old-svm": mock.Mock(vserver="os-old-svm"),
156-
expected_svm: mock.Mock(vserver=expected_svm),
165+
"os-old-svm": _create_mock_svm_lib("os-old-svm"),
166+
expected_svm: _create_mock_svm_lib(expected_svm),
157167
}
158168

159169
self.driver._get_svms = mock_get_svms
160170
# Returned by _get_svms (after refresh)
161171
mock_get_svms.return_value = [expected_svm, "os-new-svm"]
162172

163173
# make the created lib look like the real thing
164-
mock_lib_instance = mock.create_autospec(
165-
dynamic_netapp_driver.NetAppMinimalLibrary, instance=True
166-
)
167-
168-
# Mock the new lib instance created
169-
mock_lib_instance.vserver = "os-new-svm"
174+
mock_lib_instance = _create_mock_svm_lib("os-new-svm")
170175
mock_create_svm_lib.return_value = mock_lib_instance
171176

172177
# Trigger refresh

0 commit comments

Comments
 (0)