Bug 2186558

Summary: Always try to eject the cdrom even whether host was built with Auto-attach bootdisk feature or Manual attachment of Full Host Image
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: Provisioning TemplatesAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.12.3CC: lstejska, mhulan
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sayan Das 2023-04-13 17:28:58 UTC
Description of problem:

The basic code for eject_cdrom snippet is the following 

<% if @host.respond_to?(:bootdisk_build?) && @host.bootdisk_build? -%>
eject -v
<% end -%>

And we call the snippet in these many templates:

/usr/share/foreman/app/views/unattended/provisioning_templates/finish/preseed_default_finish.erb:<%= snippet 'eject_cdrom' -%>
/usr/share/foreman/app/views/unattended/provisioning_templates/provision/autoyast_default.erb:<%= snippet 'eject_cdrom' -%>
/usr/share/foreman/app/views/unattended/provisioning_templates/provision/autoyast_sles_default.erb:<%= snippet 'eject_cdrom' -%>
/usr/share/foreman/app/views/unattended/provisioning_templates/provision/kickstart_default.erb:<%= snippet 'eject_cdrom' -%>


This means, Unless we use the Auto-Attach bootdisk method where "Boot Disk Based" build option is enabled, For no other circumstances the cdrom will be ejected.

But it can prove to be problematic when a bare-metal build is happening using Full Host Boot Disk and cdrom\VirtualMedia is at the top of the Boot device order. 




Version-Release number of selected component (if applicable):

Any supported version of Satellite 6


How reproducible:

Always


Steps to Reproduce:

1. Create a blank VM and ensure that CDROM is the first boot device and Harddisk is the second 

2. Use Satellite to create a Host profile for that VM and submit it for build. 

3. Download Full Host Image for the host.

4. Upload that ISO to the VM's cdrom and boot the VM with the same

5. Let the build happen on it's own and reboot the system afterwards.



Actual results:

Once the system is marked as built in satellite, The build token is invalidated. 

So if the system reboots and boots up with the cdrom once again, Then the attached ISO will try to rebuild the system but will fail to fetch the kickstart due to an invalid token embedded in the URL.

( and system will go into emergency mode )

This can only be solved by powering off the system, ejecting the cdrom and powering it back on or else make HDD as the first boot device somehow. 


Expected results:

Unless, there some problems could happen with the overall kickstart workflow, I would expect "eject -v" to be executed at the end of each build so that the cdrom gets detached before the system reboots. 


Additional info:

NA