Fix ks_template property to be processed only for anaconda deploy

Ramdisk and anaconda deploys share image processing by
ironic.common.pxe_utils.get_instance_image_info(). This method
unnecessarily processes ks_template property when ramdisk
deploy is in use, and by itself calls _get_image_properties()
which requires image_source property to exist.
For ramdisk deploy it is enough to have kernel and ramdisk.
This patch adds conditions to process ks_template property only
for anaconda deploy.

Change-Id: I5f88d3b1da1c17bc26d49370cc6ce74644d13679
This commit is contained in:
Lana Kaleif 2023-07-24 08:23:13 -04:00
parent 2d8986bda4
commit 36665a0895

View File

@ -664,11 +664,12 @@ def get_instance_image_info(task, ipxe_enabled=False):
"""
ctx = task.context
node = task.node
boot_option = deploy_utils.get_boot_option(node)
image_info = {}
# NOTE(pas-ha) do not report image kernel and ramdisk for
# local boot or whole disk images so that they are not cached
if (node.driver_internal_info.get('is_whole_disk_image')
or deploy_utils.get_boot_option(node) == 'local'):
or boot_option == 'local'):
return image_info
root_dir = _get_root_dir(ipxe_enabled)
i_info = node.instance_info
@ -697,7 +698,9 @@ def get_instance_image_info(task, ipxe_enabled=False):
# like is done with basically Glance.
labels = ('kernel', 'ramdisk')
if not isap:
if boot_option != 'kickstart':
anaconda_labels = ()
elif not isap:
anaconda_labels = ('stage2', 'ks_template', 'ks_cfg')
else:
# When a path is used, a stage2 ramdisk can be determiend
@ -744,30 +747,32 @@ def get_instance_image_info(task, ipxe_enabled=False):
else:
node.set_driver_internal_info(
'stage2', str(image_properties['stage2_id']))
# NOTE(TheJulia): A kickstart template is entirely independent
# of the stage2 ramdisk. In the end, it was the configuration which
# told anaconda how to execute.
if i_info.get('ks_template'):
# If the value is set, we always overwrite it, in the event
# a rebuild is occuring or something along those lines.
node.set_driver_internal_info('ks_template',
i_info['ks_template'])
else:
_get_image_properties()
# ks_template is an optional property on the image
if image_properties and 'ks_template' in image_properties:
node.set_driver_internal_info(
'ks_template', str(image_properties['ks_template']))
if 'ks_template' in anaconda_labels:
# NOTE(TheJulia): A kickstart template is entirely independent
# of the stage2 ramdisk. In the end, it was the configuration which
# told anaconda how to execute.
if i_info.get('ks_template'):
# If the value is set, we always overwrite it, in the event
# a rebuild is occuring or something along those lines.
node.set_driver_internal_info('ks_template',
i_info['ks_template'])
else:
# If not defined, default to the overall system default
# kickstart template, as opposed to a user supplied
# template.
node.set_driver_internal_info(
'ks_template',
'file://' + os.path.abspath(
CONF.anaconda.default_ks_template
_get_image_properties()
# ks_template is an optional property on the image
if image_properties and 'ks_template' in image_properties:
node.set_driver_internal_info(
'ks_template', str(image_properties['ks_template']))
else:
# If not defined, default to the overall system default
# kickstart template, as opposed to a user supplied
# template.
node.set_driver_internal_info(
'ks_template',
'file://' + os.path.abspath(
CONF.anaconda.default_ks_template
)
)
)
node.save()