Skip to content

Conversation

peppi-lotta
Copy link
Member

This PR introduces a script ipa_debug_tools.sh that provides a set of utilities to assist with debugging and comparing IPA (ironic-python-agent) initramfs builds. The script is particularly useful for identifying differences between locally built IPA images and the official master images.

This tool is meant especially for situations where built IPA size get over a certain limit limit and two file systems need to be compared.


🛠️ What's Included

  • set_up_debug_dirs

    • Sets up a local debug environment under /tmp/debug-initramfs
    • Builds the local IPA using jenkins/scripts/dynamic_worker_workflow/build_ipa.sh
    • Downloads and extracts the master IPA image from upstream
  • compare_dir_sizes [path]

    • Compares sizes of files/directories between the local build and master IPA
    • Provides a colored, sorted table of size differences
    • Highlights large discrepancies (10MB+, 1MB+, etc.)
    • Lists files exclusive to either initramfs tree
image
  • compare_rpm_packages
    • Extracts and compares installed RPMs between local and master IPA environments
    • Outputs side-by-side view of mismatched or missing packages
    • Helps identify unintended package changes
image
  • clean_up_debug_dirs
    • Deletes all temporary directories and files created during debugging

@metal3-io-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tuminoid for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 29, 2025
@peppi-lotta peppi-lotta force-pushed the peppi-lotta/add-ipa-debug-tool branch 2 times, most recently from 4c2b687 to 9e9d4b4 Compare July 30, 2025 06:15
Copy link
Member

@Rozzii Rozzii left a comment

Choose a reason for hiding this comment

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

In general LGTM,
It is a very useful tool as I have mentioned offline.
I have one improvement proposal but it can be a later addition if you don't feel like implementing it now.

sudo mkdir -p /tmp/debug-initramfs/master-ipa-initramfs
cd /tmp/debug-initramfs || exit
sudo wget https://tarballs.opendev.org/openstack/ironic-python-agent/dib/ipa-centos9-master.tar.gz
sudo tar -xzf ipa-centos9-master.tar.gz
Copy link
Member

@Rozzii Rozzii Jul 31, 2025

Choose a reason for hiding this comment

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

It would be nice if the upstream IPA URI and tar file name could be customized same as in IPA downloader, you could actually use IPA downloader here instead of your own download logic to keep it simple .

Copy link
Member

Choose a reason for hiding this comment

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

For debug tool, it might be good enough to be able to supply the URL. get-resource.sh vs one-liner... I'd go for the latter.

Copy link
Member

Choose a reason for hiding this comment

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

I am fine either way, but the url and the name of the tar file has to be customizable because otherwise only a specific master on a specific base image can be tested. I suggested to use the downloader because that has all the customization options implemented but I am fine with doing it with the one liners too.

@Rozzii
Copy link
Member

Rozzii commented Jul 31, 2025

/override metal3-ubuntu-e2e-integration-test-main
This is a hacktool for manual testing, not used in CI jet.

@metal3-io-bot
Copy link
Collaborator

@Rozzii: Overrode contexts on behalf of Rozzii: metal3-ubuntu-e2e-integration-test-main

In response to this:

/override metal3-ubuntu-e2e-integration-test-main
This is a hacktool for manual testing, not used in CI jet.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Rozzii Rozzii moved this to MISC WIP in Metal3 - Roadmap Jul 31, 2025
Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

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

This is great addition to debug tools, thanks @peppi-lotta.

Some cleanup to do, some minor syntax things to fix and some suggestions to make it more readable and maintainable.

sudo mkdir -p /tmp/debug-initramfs/master-ipa-initramfs
cd /tmp/debug-initramfs || exit
sudo wget https://tarballs.opendev.org/openstack/ironic-python-agent/dib/ipa-centos9-master.tar.gz
sudo tar -xzf ipa-centos9-master.tar.gz
Copy link
Member

Choose a reason for hiding this comment

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

For debug tool, it might be good enough to be able to supply the URL. get-resource.sh vs one-liner... I'd go for the latter.

@peppi-lotta peppi-lotta force-pushed the peppi-lotta/add-ipa-debug-tool branch 2 times, most recently from 00054eb to 7a7af56 Compare September 29, 2025 09:51
# -----------------------------------------------------------------------------
clean_up_debug_dirs() {
# Clean up debug directories
sudo rm -rf "${BASE_DEBUG_DIR}" /tmp/dib ipa-file-injector.service 2> /dev/null
Copy link
Member

@Rozzii Rozzii Sep 29, 2025

Choose a reason for hiding this comment

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

I get "${BASE_DEBUG_DIR}" and /tmp/dib but how does ipa-file-injector.service end up here?
I don't see any other reference to that file, and AFAIK that is the systemd unit file of the similarly named DIB module. It could be that I am missing something here but looks like this is some leftover reference maybe.

Copy link
Member Author

Choose a reason for hiding this comment

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

ipa-file-injector.service appears in the /tmp directory after running the build-ip.sh. That is why I've added that to the clean up as well.

Copy link
Member

Choose a reason for hiding this comment

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

okay, that might be then some sort of residue from the template rendering process. I might remove it later, but then it is fine to remove it here.

Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

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

IMO colors are fine, but emojis not.

@peppi-lotta peppi-lotta force-pushed the peppi-lotta/add-ipa-debug-tool branch from 7a7af56 to 27494cb Compare October 3, 2025 07:16
Copy link
Member

@Rozzii Rozzii left a comment

Choose a reason for hiding this comment

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

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 7, 2025
@peppi-lotta
Copy link
Member Author

@tuminoid I've addressed all comment can you approve and override test?

@tuminoid
Copy link
Member

It doesn't work?

2025-10-20 07:35:48.405 | + diskimage_builder/lib/common-functions:tmpfs_check:29                            :   return 0
2025-10-20 07:35:48.409 | + diskimage_builder/lib/common-functions:cleanup_image_dir:236                     :   timeout 120 sh -c 'while ! sudo umount -f /tmp/dib_image.Jc5gaKZ3; do sleep 1; done'
2025-10-20 07:35:48.426 | + diskimage_builder/lib/common-functions:cleanup_image_dir:241                     :   rm -rf --one-file-system /tmp/dib_image.Jc5gaKZ3
2025-10-20 07:35:48.431 | + diskimage_builder/lib/img-functions:trap_cleanup:37                              :   exit 1
Command '['disk-image-create', '-o', 'ironic-python-agent', 'ironic-python-agent-ramdisk', 'centos', 'dynamic-login', 'journal-to-console', 'devuser', 'openssh-server', 'extra-hardware', 'ipa-module-autoload', 'ipa-add-buildinfo', 'ipa-cleanup-dracut', 'simple-init', 'override-simple-init', 'ipa-file-injector', 'cleanup-package', '-x']' returned non-zero exit status 1.
build_ipa.sh failed, will check for artifact...
Required file '/tmp/dib/ironic-python-agent.initramfs' not created, exiting.

Running the test with using default options (centos10 master, opendev dib url).

Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

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

Not exactly fond of that it just asks for sudo password and then goes and installs stuff on the system. Installing anything should be another "subcommand" that user must run explicitly.

The sudo usage in general is also very liberal (please don't run sudo wget and sudo tar .... Making a temporary directory with sudo is not typical either.

Sudo chroot also is not needed.

# The path to the directory that holds this script
CURRENT_SCRIPT_DIR="$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")")"
BASE_DEBUG_DIR="/tmp/debug-initramfs"
mkdir -p ${BASE_DEBUG_DIR}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mkdir -p ${BASE_DEBUG_DIR}
mkdir -p "${BASE_DEBUG_DIR}"

build_rpm_list_name_bases=$(mktemp -p "${BASE_HELPER_FILE_DIR}")
master_rpm_list_name_bases=$(mktemp -p "${BASE_HELPER_FILE_DIR}")

sudo chroot "${build_dir}" rpm -qa | sort > "${build_rpm_list}"
Copy link
Member

Choose a reason for hiding this comment

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

rpm --root "${build_dir}" -qa should do the trick without sudo chroot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: MISC WIP

Development

Successfully merging this pull request may close these issues.

4 participants