diff options
author | Aija Jauntēva <aija.jaunteva@dell.com> | 2021-12-29 08:26:34 -0500 |
---|---|---|
committer | Aija Jauntēva <aija.jaunteva@dell.com> | 2022-07-01 09:09:11 -0400 |
commit | c9c8514a37b8607734f8c7a7e1bc59399c0ad240 (patch) | |
tree | d6c67963eee3766ba491d09dc5420808a749e190 | |
parent | 4d9751ed392a72ccf1325d736f3daa1938d2ecc9 (diff) | |
download | ironic-c9c8514a37b8607734f8c7a7e1bc59399c0ad240.tar.gz |
Fix prepare ramdisk for 'wait' states
Node can be in CLEANWAIT or DEPLOYWAIT during async step
handling when it needs another reboot. Without this change
node fails to boot back to IPA.
This unifies all occurrences and create utility method for
reuse. All occurrences are aligned to have the same set of
states in case they are needed in future.
Conflicts:
ironic/drivers/utils.py
Change-Id: I685c5827a70df4abb358635d89b86894671ac493
(cherry picked from commit dd1cb46f2b0146524f0cb4d3579ac5c5b9a6fa45)
-rw-r--r-- | ironic/drivers/modules/ilo/boot.py | 18 | ||||
-rw-r--r-- | ironic/drivers/modules/irmc/boot.py | 8 | ||||
-rw-r--r-- | ironic/drivers/modules/redfish/boot.py | 9 | ||||
-rw-r--r-- | ironic/drivers/utils.py | 21 |
4 files changed, 25 insertions, 31 deletions
diff --git a/ironic/drivers/modules/ilo/boot.py b/ironic/drivers/modules/ilo/boot.py index 0452418fa..7755508ba 100644 --- a/ironic/drivers/modules/ilo/boot.py +++ b/ironic/drivers/modules/ilo/boot.py @@ -420,14 +420,7 @@ class IloVirtualMediaBoot(base.BootInterface): """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, such as conductor takeover, - # we should treat this as a no-op and move on otherwise we would - # modify the state of the node due to virtual media operations. - if node.provision_state not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return prepare_node_for_deploy(task) @@ -1066,14 +1059,7 @@ class IloUefiHttpsBoot(base.BootInterface): :raises: IloOperationError, if some operation on iLO failed. """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, such as conductor takeover, - # we should treat this as a no-op and move on otherwise we would - # modify the state of the node due to virtual media operations. - if node.provision_state not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return prepare_node_for_deploy(task) diff --git a/ironic/drivers/modules/irmc/boot.py b/ironic/drivers/modules/irmc/boot.py index 60ab2fa2e..69a817c02 100644 --- a/ironic/drivers/modules/irmc/boot.py +++ b/ironic/drivers/modules/irmc/boot.py @@ -968,13 +968,7 @@ class IRMCVirtualMediaBoot(base.BootInterface, IRMCVolumeBootMixIn): :raises: IRMCOperationError, if some operation on iRMC fails. """ - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, such as conductor takeover, - # we should treat this as a no-op and move on otherwise we would - # modify the state of the node due to virtual media operations. - if task.node.provision_state not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING): + if not driver_utils.need_prepare_ramdisk(task.node): return # NOTE(tiendc): Before deploying, we need to backup BIOS config diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 9d3ee99e0..d9d1fef50 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -486,14 +486,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): operation failed on the node. """ node = task.node - # NOTE(TheJulia): If this method is being called by something - # aside from deployment, clean and rescue, such as conductor takeover, - # we should treat this as a no-op and move on otherwise we would - # modify the state of the node due to virtual media operations. - if node.provision_state not in (states.DEPLOYING, - states.CLEANING, - states.RESCUING, - states.INSPECTING): + if not driver_utils.need_prepare_ramdisk(node): return d_info = _parse_driver_info(node) diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index 4aa2335d6..1debeed90 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -23,6 +23,7 @@ from oslo_utils import timeutils from ironic.common import exception from ironic.common.i18n import _ +from ironic.common import states from ironic.common import swift from ironic.conductor import utils from ironic.drivers import base @@ -384,3 +385,23 @@ OPTIONAL_PROPERTIES = { "deprecated in favor of the new ones." "Defaults to 'Default'. Optional."), } + + +def need_prepare_ramdisk(node): + """Check if node needs preparing ramdisk + + :param node: Node to check for + :returns: True if need to prepare ramdisk, otherwise False + """ + # NOTE(TheJulia): If current node provisioning is something aside from + # deployment, clean, rescue or inspect such as conductor takeover, + # we should treat this as a no-op and move on otherwise we would + # modify the state of the node due to virtual media operations. + return node.provision_state in (states.DEPLOYING, + states.DEPLOYWAIT, + states.CLEANING, + states.CLEANWAIT, + states.RESCUING, + states.RESCUEWAIT, + states.INSPECTING, + states.INSPECTWAIT) |