From 6fa142160e99ef6433a6f200511ef78f66b19f45 Mon Sep 17 00:00:00 2001 From: Luong Anh Tuan Date: Mon, 26 Sep 2016 16:06:28 +0700 Subject: [PATCH] Fix setting persistent boot device does not work - The old value 'is_next_boot_persistent'=False of "driver_internal_info" is still in database, Because when persistent set is True we didn't set 'is_next_boot_persistent'=True. This will lead to get_boot_device work wrong in response boot information. https://github.com/openstack/ironic/blob/70b992c/ironic/drivers/modules/ipmitool.py#L975 or https://github.com/openstack/ironic/blob/70b992c/ironic/drivers/modules/ipminative.py#L501 Thus we have to pop "is_next_boot_persistent" to fix the problem. Co-Authored-By: Dmitry Tantsur Change-Id: I79efed519b2bacf178f078b338394ca0c4e87d4f Closes-bug: #1626453 --- ironic/drivers/utils.py | 1 + ironic/tests/unit/drivers/test_utils.py | 6 ++++-- releasenotes/notes/bug-1626453-e8df46aa5db6dd5a.yaml | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-1626453-e8df46aa5db6dd5a.yaml diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index 6247e1fb13..fe1a1c5f21 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -220,6 +220,7 @@ def force_persistent_boot(task, device, persistent): node = task.node driver_internal_info = node.driver_internal_info if persistent: + driver_internal_info.pop('is_next_boot_persistent', None) driver_internal_info['persistent_boot_device'] = device else: driver_internal_info['is_next_boot_persistent'] = False diff --git a/ironic/tests/unit/drivers/test_utils.py b/ironic/tests/unit/drivers/test_utils.py index 12361e503d..c0952bf078 100644 --- a/ironic/tests/unit/drivers/test_utils.py +++ b/ironic/tests/unit/drivers/test_utils.py @@ -158,8 +158,10 @@ class UtilsTestCase(db_base.DbTestCase): ret = driver_utils.force_persistent_boot(task, 'pxe', True) self.assertIsNone(ret) task.node.refresh() - self.assertIn('persistent_boot_device', - task.node.driver_internal_info) + self.assertIn(('persistent_boot_device', 'pxe'), + task.node.driver_internal_info.items()) + self.assertNotIn('is_next_boot_persistent', + task.node.driver_internal_info) def test_force_persistent_boot_false(self): with task_manager.acquire(self.context, self.node.uuid, diff --git a/releasenotes/notes/bug-1626453-e8df46aa5db6dd5a.yaml b/releasenotes/notes/bug-1626453-e8df46aa5db6dd5a.yaml new file mode 100644 index 0000000000..70ac590ae4 --- /dev/null +++ b/releasenotes/notes/bug-1626453-e8df46aa5db6dd5a.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - This fixes the issue setting persistent boot device does not work + with ipmi_force_boot_device=True. For more information, see + https://bugs.launchpad.net/ironic/+bug/1626453