From a7623d92dc4d7c7bcc436656b93c8fe963e79bfd Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 10 Jan 2018 15:51:20 +0100 Subject: [PATCH] Do not validate root partition size for whole disk images in iscsi deploy On whole disk images a root partition is already created and populated, so validating its size makes no sense. We don't do it for direct deploy. Change-Id: I7a4114979afb310aeb77f99fbcf09ef7c54862d6 Closes-Bug: #1742451 --- ironic/drivers/modules/iscsi_deploy.py | 7 +++++++ .../tests/unit/drivers/modules/test_iscsi_deploy.py | 11 +++++++++++ .../notes/iscsi-whole-disk-cd464d589d029b01.yaml | 6 ++++++ 3 files changed, 24 insertions(+) create mode 100644 releasenotes/notes/iscsi-whole-disk-cd464d589d029b01.yaml diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py index 4e255ad16d..392837022c 100644 --- a/ironic/drivers/modules/iscsi_deploy.py +++ b/ironic/drivers/modules/iscsi_deploy.py @@ -88,10 +88,17 @@ def _save_disk_layout(node, i_info): def check_image_size(task): """Check if the requested image is larger than the root partition size. + Does nothing for whole-disk images. + :param task: a TaskManager instance containing the node to act on. :raises: InstanceDeployFailure if size of the image is greater than root partition. """ + if task.node.driver_internal_info['is_whole_disk_image']: + # The root partition is already created and populated, no use + # validating its size + return + i_info = deploy_utils.parse_instance_info(task.node) image_path = _get_image_file_path(task.node.uuid) image_mb = disk_utils.get_image_mb(image_path) diff --git a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py index e3d961e366..15e3ecc893 100644 --- a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py +++ b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py @@ -117,6 +117,17 @@ class IscsiDeployMethodsTestCase(db_base.DbTestCase): get_image_mb_mock.assert_called_once_with( iscsi_deploy._get_image_file_path(task.node.uuid)) + @mock.patch.object(disk_utils, 'get_image_mb', autospec=True) + def test_check_image_size_whole_disk_image(self, get_image_mb_mock): + get_image_mb_mock.return_value = 1025 + with task_manager.acquire(self.context, self.node.uuid, + shared=False) as task: + task.node.instance_info['root_gb'] = 1 + task.node.driver_internal_info['is_whole_disk_image'] = True + # No error for whole disk images + iscsi_deploy.check_image_size(task) + self.assertFalse(get_image_mb_mock.called) + @mock.patch.object(disk_utils, 'get_image_mb', autospec=True) def test_check_image_size_fails(self, get_image_mb_mock): get_image_mb_mock.return_value = 1025 diff --git a/releasenotes/notes/iscsi-whole-disk-cd464d589d029b01.yaml b/releasenotes/notes/iscsi-whole-disk-cd464d589d029b01.yaml new file mode 100644 index 0000000000..e910b32120 --- /dev/null +++ b/releasenotes/notes/iscsi-whole-disk-cd464d589d029b01.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + No longer validates requested root partition size for whole-disk images + using ``iscsi`` deploy interface, see `bug 1742451 + `_ for details.