diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 205fb39fa3..38a16c2f8d 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -1123,7 +1123,9 @@ def parse_instance_info(node): " in node's instance_info") check_for_missing_params(i_info, error_msg) - i_info['swap_mb'] = int(info.get('swap_mb', 0)) + # NOTE(vdrok): We're casting disk layout parameters to int only after + # ensuring that it is possible + i_info['swap_mb'] = info.get('swap_mb', 0) i_info['ephemeral_gb'] = info.get('ephemeral_gb', 0) err_msg_invalid = _("Cannot validate parameter for driver deploy. " "Invalid parameter %(param)s. Reason: %(reason)s") @@ -1136,10 +1138,12 @@ def parse_instance_info(node): {'param': param, 'reason': reason}) - i_info['root_mb'] = 1024 * int(info.get('root_gb')) + i_info['root_mb'] = 1024 * int(i_info['root_gb']) + i_info['swap_mb'] = int(i_info['swap_mb']) + i_info['ephemeral_mb'] = 1024 * int(i_info['ephemeral_gb']) if iwdi: - if int(i_info['swap_mb']) > 0 or int(i_info['ephemeral_gb']) > 0: + if i_info['swap_mb'] > 0 or i_info['ephemeral_mb'] > 0: err_msg_invalid = _("Cannot deploy whole disk image with " "swap or ephemeral size set") raise exception.InvalidParameterValue(err_msg_invalid) diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py index 82d05b28e2..0418131573 100644 --- a/ironic/drivers/modules/iscsi_deploy.py +++ b/ironic/drivers/modules/iscsi_deploy.py @@ -207,9 +207,9 @@ def get_deploy_info(node, address, iqn, port=None, lun='1'): is_whole_disk_image = node.driver_internal_info['is_whole_disk_image'] if not is_whole_disk_image: - params.update({'root_mb': 1024 * int(i_info['root_gb']), - 'swap_mb': int(i_info['swap_mb']), - 'ephemeral_mb': 1024 * int(i_info['ephemeral_gb']), + params.update({'root_mb': i_info['root_mb'], + 'swap_mb': i_info['swap_mb'], + 'ephemeral_mb': i_info['ephemeral_mb'], 'preserve_ephemeral': i_info['preserve_ephemeral'], 'boot_option': deploy_utils.get_boot_option(node), 'boot_mode': _get_boot_mode(node)}) diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index 07ac3827b4..c44ad90ac1 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -2125,6 +2125,7 @@ class InstanceInfoTestCase(db_base.DbTestCase): def test_parse_instance_info_valid_ephemeral_gb(self): ephemeral_gb = 10 + ephemeral_mb = 1024 * ephemeral_gb ephemeral_fmt = 'test-fmt' info = dict(INST_INFO_DICT) info['ephemeral_gb'] = ephemeral_gb @@ -2134,7 +2135,7 @@ class InstanceInfoTestCase(db_base.DbTestCase): driver_internal_info=DRV_INTERNAL_INFO_DICT, ) data = utils.parse_instance_info(node) - self.assertEqual(ephemeral_gb, data['ephemeral_gb']) + self.assertEqual(ephemeral_mb, data['ephemeral_mb']) self.assertEqual(ephemeral_fmt, data['ephemeral_format']) def test_parse_instance_info_unicode_swap_mb(self): @@ -2308,9 +2309,9 @@ class InstanceInfoTestCase(db_base.DbTestCase): ) instance_info = utils.parse_instance_info(node) self.assertIsNotNone(instance_info['image_source']) - self.assertIsNotNone(instance_info['root_gb']) + self.assertIsNotNone(instance_info['root_mb']) self.assertEqual(0, instance_info['swap_mb']) - self.assertEqual(0, instance_info['ephemeral_gb']) + self.assertEqual(0, instance_info['ephemeral_mb']) self.assertIsNone(instance_info['configdrive']) def test_parse_instance_info_whole_disk_image_missing_root(self): diff --git a/releasenotes/notes/fix-ipa-ephemeral-partition-1f1e020727a49078.yaml b/releasenotes/notes/fix-ipa-ephemeral-partition-1f1e020727a49078.yaml new file mode 100644 index 0000000000..ff392b614f --- /dev/null +++ b/releasenotes/notes/fix-ipa-ephemeral-partition-1f1e020727a49078.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Fixed a bug where the ironic python agent ramdisk was not creating an + ephemeral partition because the ephemeral partition size was not being + passed correctly to the agent.