Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts for local boot.iso updates workflow #5525

Merged

Conversation

M4rtinK
Copy link
Contributor

@M4rtinK M4rtinK commented Mar 22, 2024

A couple scripts for easily building a boot.iso from Anaconda source code & then using that as a base image for creating another boot.iso wit updates image, for fast debug iteration.

The general idea is to build (or download) a boot.iso first with any of the invasive changes (eq. added/removed packages) and then putting any ongoing changes to the "updated" boot.iso & periodically booting it in a VM.

The boot.iso update script also makes it possible to easily inject any additional boot options & automatically includes a timestamp via dummy boot option, so you can easily check which version of the image you are actually running.

NOTE: pretty much under heavy development & not final just yet.

TODO:

  • support for adding boot options
  • add HOWTO guide into Anaconda docs
  • finish the virt-install invocation support
  • incorporate imporvements from @adamkankovsky branch - thanks! :)

@M4rtinK M4rtinK added the blocked Don't merge this pull request! label Mar 22, 2024
@github-actions github-actions bot added the f41 label Mar 22, 2024
scripts/update_boot_iso Fixed Show fixed Hide fixed
scripts/update_boot_iso Fixed Show fixed Hide fixed
@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 04af764 to 8061204 Compare March 22, 2024 14:02
Copy link

This PR is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale label May 22, 2024
@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 8061204 to 42063a8 Compare June 18, 2024 12:29
@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 42063a8 to 1e22203 Compare June 18, 2024 12:43
@M4rtinK M4rtinK removed the stale label Jun 18, 2024
@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 1e22203 to 2664976 Compare June 18, 2024 14:07
@jkonecny12
Copy link
Member

We should start using directory structure to show which tools are usable in the installed environment or used for development on the dev machine.

@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 2664976 to 9cbdddb Compare June 19, 2024 11:53
@M4rtinK
Copy link
Contributor Author

M4rtinK commented Jun 19, 2024

We should start using directory structure to show which tools are usable in the installed environment or used for development on the dev machine.

Seems like a suitable objective for a followup PR. :)

@M4rtinK
Copy link
Contributor Author

M4rtinK commented Jun 19, 2024

Updated PR with improvements from @adamkankovsky, such as:

  • more robust path handling
  • kickstart support
  • custom boot option support

Thanks! :)

@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 9cbdddb to 4de43db Compare June 19, 2024 12:40
@M4rtinK M4rtinK changed the title WIP: Scripts for local boot.iso updates workflow Scripts for local boot.iso updates workflow Jun 19, 2024
@M4rtinK
Copy link
Contributor Author

M4rtinK commented Jun 19, 2024

Added simple virt-install support. :)

@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 4de43db to c3abca3 Compare June 20, 2024 13:00
@M4rtinK M4rtinK marked this pull request as ready for review June 20, 2024 13:30
@M4rtinK M4rtinK removed the blocked Don't merge this pull request! label Jun 20, 2024
@jkonecny12
Copy link
Member

Please fix the pylint issue:

W1510(subprocess-run-check):/tmp/anaconda/scripts/update_boot_iso:202,4: run_updated_iso_with_virt_install: 'subprocess.run' used without explicitly defining the value for 'check'.

CONTRIBUTING.rst Outdated Show resolved Hide resolved
CONTRIBUTING.rst Outdated Show resolved Hide resolved
print("** error: could not determine a valid commit id")
sys.exit(1)

print("** preparing updates image via tag/hash: %s" % git_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, don't want to be picky, but looking at the code convention guideline, it states that we should use format() instead of %s.

Since this is a script that is mainly intended for development purposes, is it fine if we just ignore that convention?

https://github.com/rhinstaller/anaconda/blob/master/CONTRIBUTING.rst#code-conventions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I saw that in line 120 you are using f-strings. So maybe this is some older code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have been discussing this recently & we might be changing/cleaning up the guidelines soon. It was quite a while ago, when f-strings were quite new and not that well supported and used everywhere. We will most likely switch to allowing f-strings with some guidelines.

But there are still some issues we will need to look into, that are kinda specific to the tooling Anaconda is using:

  • The Python Logging module has its own "% like" syntax for string formatting that does not behave the same as regular Python strings formatted in the same manner & prevented use from using format() for logged strings.
  • For f-strings, there are some issues with translated strings (IIRC we might end up with f-strings after the substitution being done marked for translation, which is wrong. 📦

So we might end up with:

  • % syntax for logging
  • % or format() for translated strings
  • f-strings elsewhere

@M4rtinK
Copy link
Contributor Author

M4rtinK commented Jul 2, 2024

Please fix the pylint issue:

W1510(subprocess-run-check):/tmp/anaconda/scripts/update_boot_iso:202,4: run_updated_iso_with_virt_install: 'subprocess.run' used without explicitly defining the value for 'check'.

Should be fixed now. :)

@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 1049348 to 488da58 Compare July 3, 2024 14:59
uses the Anaconda updates image mechanism together with the ``mkksiso`` command provided by the Lorax project to very quickly
create an updated version of the boot.iso when Anaconda code is changed. The updated boot.iso can then be booted on a VM or bare metal.

The ``rebuild_boot_iso`` script
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that the script explanation is inside the script on the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a small note to each script noting what it does & where to find more. I kinda like to have both scripts documented in a single place to which I can direct people to.


The script also has a few command line options that might come handy:

* ``-b, --boot-options`` makes it possible to add additional boot options to the boot.iso boot menu
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly I think if the script has help proper implemented I dont think we need to document this extra here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is beneficial to be able to see the argument at a glance without having to execute the script first - kinda like a man file. Also it is possible to be more verbose here, if necessary, than in the limited environment of the --help option.

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see CONTRIBUTING file getting tidied up, but I am ok to unblock this.

M4rtinK and others added 2 commits July 10, 2024 14:55
A set of two script for easy local Anaconda development and debugging.

Can be also used to easily create bootable installation images
for demonstration purposes or for easy creation of bug reproducer
images.

The first script - rebuild_boot_iso - builds an Anaconda boot.iso
from the current branch + distro packages. The script also stores the
git revision of Anaconda branch at that time - which becomes important
later. Expected is about 15 minutes on modern hardware with good
connectivity for package download.

The second script - update_boot_iso - works with the image generated
by the first script. It adds changes present in the current working
directory to an updates image, then appends this updates image to the
boot.iso via the wonderful mkksiso tool. This takes a couple seconds on
modern hardware.

By default the scripts work automatically as git revision for the boot.iso
at build time is stored & anything added since the revision will be added
automatically via the updates image.

Note that the script also adds a dummy boot option that records when the
updated image has been built. This way it is possible to easily check what
version of the image you re actually running, just by looking at
/proc/cmdline from inside of the VM.

The end result are two bootable installation images in the result/iso
directory:

- boot.iso - the "clean" generated installation image
- updated_boot.iso - updated boot iso with baked-in updates image

The idea behind this is, that during regular development, the
rebuild_boot_iso script will be run infrequently (eq. when changing
Anaconda dependencies) & the fast update_boot_iso will be run every time
a code change is to be tested, booting it in a VM afterwards.

This way it should be possible to avoid using big and fragile updates
images as well as making the change-debug cycle as fast as possible, all
without depending on external infrastructure.
Thanks for the improvements! :)

Co-authored-by: Rodolfo Olivieri <[email protected]>
@M4rtinK M4rtinK force-pushed the master-local_image_udates_workflow branch from 488da58 to b1c09f4 Compare July 10, 2024 12:55
@M4rtinK M4rtinK merged commit 0723f93 into rhinstaller:master Jul 10, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 participants