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 from 1a30ce3 to 4c2b687 Compare July 30, 2025 06:07
Signed-off-by: peppi-lotta <peppi-lotta.saari@est.tech>
@peppi-lotta peppi-lotta force-pushed the peppi-lotta/add-ipa-debug-tool branch 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.

@@ -0,0 +1,227 @@
#!/usr/bin/env bash

Copy link
Member

Choose a reason for hiding this comment

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

We should be running with set -eu by default.

export TEST_IN_CI="false"

# Build ipa with build_ipa.sh
cd "$CURRENT_SCRIPT_DIR/../jenkins/scripts/dynamic_worker_workflow" || exit
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
cd "$CURRENT_SCRIPT_DIR/../jenkins/scripts/dynamic_worker_workflow" || exit
cd "${CURRENT_SCRIPT_DIR}/../jenkins/scripts/dynamic_worker_workflow"

|| exit 1 not needed if we're running set -e mentioned earlier, cleans up the code.

# Unzip ironic-python-agent.initramfs
sudo mkdir -p /tmp/debug-initramfs/build-ipa-initramfs
sudo cp /tmp/dib/ironic-python-agent.initramfs /tmp/debug-initramfs/
cd /tmp/debug-initramfs/build-ipa-initramfs || exit
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
cd /tmp/debug-initramfs/build-ipa-initramfs || exit
cd /tmp/debug-initramfs/build-ipa-initramfs

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.

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
cd master-ipa-initramfs || exit
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
cd master-ipa-initramfs || exit
cd master-ipa-initramfs

#the built ipa and master.
# Check if packages are a part of CentOS Stream in https://pkgs.org
compare_rpm_packages() {
basedir1="${1:-/tmp/debug-initramfs/build-ipa-initramfs}"
Copy link
Member

Choose a reason for hiding this comment

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

Same as above for descriptive dir and files names.

common_count=$(comm -12 "${compfile1}" "${compfile2}" | wc -l)
echo -e "\nNumber of common packages: ${common_count}\n"
# Extract base package names and join for fuzzy matching
awk -F'-[0-9]' '{print $1}' "${compfile1}" | sort > /tmp/build-ipa-base.txt
Copy link
Member

Choose a reason for hiding this comment

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

Same suggestion for tmpfile names.

lfull=$(grep -m1 "^${left}-" "${compfile1}" || echo "")
rfull=$(grep -m1 "^${right}-" "${compfile2}" || echo "")
# Skip printing if both lines are non-empty and exactly the same
if [[ -n "${lfull}" && "${lfull}" == "${rfull}" ]]; then
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
if [[ -n "${lfull}" && "${lfull}" == "${rfull}" ]]; then
if [[ -n "${lfull}" ]] && [[ "${lfull}" == "${rfull}" ]]; then

function_name="$1"
shift

# Check if function exists and call it
Copy link
Member

Choose a reason for hiding this comment

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

Why not use standard argument parsing here, much more readable and reliable?

# Usage:
# ./ipa_debug_tools.sh clean_up_debug_dirs
# -----------------------------------------------------------------------------
clean_up_debug_dirs() {
Copy link
Member

Choose a reason for hiding this comment

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

Cleaning up all the temp files should be done here, and the cleanup should be trapped function so it gets called even if we exit mid run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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