From 519edb48f13c0752c32935852b38c11b93ff180d Mon Sep 17 00:00:00 2001 From: Aija Jaunteva Date: Fri, 17 Apr 2020 15:22:33 +0300 Subject: [PATCH] Fix RAID configuration with idrac-wsman interface Change check from DracRAID to DracWSManRAID that also covers DracRAID as subclass of DracWSManRAID. Change-Id: Ib9279db88cfe154d693451add57273ec9b449ba5 Story: 2007567 Task: 39458 --- ironic/drivers/modules/drac/raid.py | 2 +- .../modules/drac/test_periodic_task.py | 37 +++++++++++++------ ...g-2007567-wsman-raid-48483affdd9f9894.yaml | 6 +++ 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 releasenotes/notes/bug-2007567-wsman-raid-48483affdd9f9894.yaml diff --git a/ironic/drivers/modules/drac/raid.py b/ironic/drivers/modules/drac/raid.py index 4e5cbce18d..7709e6d9fb 100644 --- a/ironic/drivers/modules/drac/raid.py +++ b/ironic/drivers/modules/drac/raid.py @@ -1203,7 +1203,7 @@ class DracWSManRAID(base.RAIDInterface): with task_manager.acquire(context, node_uuid, purpose=lock_purpose, shared=True) as task: - if not isinstance(task.driver.raid, DracRAID): + if not isinstance(task.driver.raid, DracWSManRAID): continue job_ids = driver_internal_info.get('raid_config_job_ids') diff --git a/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py b/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py index fb0f53f51c..a4392f2696 100644 --- a/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py +++ b/ironic/tests/unit/drivers/modules/drac/test_periodic_task.py @@ -36,6 +36,7 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): driver='idrac', driver_info=INFO_DICT) self.raid = drac_raid.DracRAID() + self.raid_wsman = drac_raid.DracWSManRAID() self.job = { 'id': 'JID_001436912645', 'name': 'ConfigBIOS:BIOS.Setup.1-1', @@ -58,8 +59,14 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): 'pending_operations': None } + def test__query_raid_config_job_status_drac(self): + self._test__query_raid_config_job_status(self.raid) + + def test__query_raid_config_job_status_drac_wsman(self): + self._test__query_raid_config_job_status(self.raid_wsman) + @mock.patch.object(task_manager, 'acquire', autospec=True) - def test__query_raid_config_job_status(self, mock_acquire): + def _test__query_raid_config_job_status(self, raid, mock_acquire): # mock node.driver_internal_info driver_internal_info = {'raid_config_job_ids': ['42']} self.node.driver_internal_info = driver_internal_info @@ -70,33 +77,41 @@ class DracPeriodicTaskTestCase(db_base.DbTestCase): {'raid_config_job_ids': ['42']})] mock_manager.iter_nodes.return_value = node_list # mock task_manager.acquire - task = mock.Mock(node=self.node, driver=mock.Mock(raid=self.raid)) + task = mock.Mock(node=self.node, driver=mock.Mock(raid=raid)) mock_acquire.return_value = mock.MagicMock( __enter__=mock.MagicMock(return_value=task)) # mock _check_node_raid_jobs - self.raid._check_node_raid_jobs = mock.Mock() + raid._check_node_raid_jobs = mock.Mock() - self.raid._query_raid_config_job_status(mock_manager, - self.context) + raid._query_raid_config_job_status(mock_manager, + self.context) - self.raid._check_node_raid_jobs.assert_called_once_with(task) + raid._check_node_raid_jobs.assert_called_once_with(task) + + def test__query_raid_config_job_status_no_config_jobs_drac(self): + self._test__query_raid_config_job_status_no_config_jobs(self.raid) + + def test__query_raid_config_job_status_no_config_jobs_drac_wsman(self): + self._test__query_raid_config_job_status_no_config_jobs( + self.raid_wsman) @mock.patch.object(task_manager, 'acquire', autospec=True) - def test__query_raid_config_job_status_no_config_jobs(self, mock_acquire): + def _test__query_raid_config_job_status_no_config_jobs(self, raid, + mock_acquire): # mock manager mock_manager = mock.Mock() node_list = [(self.node.uuid, 'idrac', '', {})] mock_manager.iter_nodes.return_value = node_list # mock task_manager.acquire - task = mock.Mock(node=self.node, driver=mock.Mock(raid=self.raid)) + task = mock.Mock(node=self.node, driver=mock.Mock(raid=raid)) mock_acquire.return_value = mock.MagicMock( __enter__=mock.MagicMock(return_value=task)) # mock _check_node_raid_jobs - self.raid._check_node_raid_jobs = mock.Mock() + raid._check_node_raid_jobs = mock.Mock() - self.raid._query_raid_config_job_status(mock_manager, None) + raid._query_raid_config_job_status(mock_manager, None) - self.assertEqual(0, self.raid._check_node_raid_jobs.call_count) + self.assertEqual(0, raid._check_node_raid_jobs.call_count) def test__query_raid_config_job_status_no_nodes(self): # mock manager diff --git a/releasenotes/notes/bug-2007567-wsman-raid-48483affdd9f9894.yaml b/releasenotes/notes/bug-2007567-wsman-raid-48483affdd9f9894.yaml new file mode 100644 index 0000000000..b58e3972e9 --- /dev/null +++ b/releasenotes/notes/bug-2007567-wsman-raid-48483affdd9f9894.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes RAID configuration using `idrac-wsman` RAID interface where node + remains in 'clean wait' provisioning state forever. + See `story 2007567 `_.