Skip to content

Conversation

@MiriamDeng
Copy link
Contributor

@MiriamDeng MiriamDeng commented Nov 18, 2025

Signed-off-by: Miriam Deng [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Fixed version string handling to ensure correct image renaming during upgrade operations, preventing mismatches when version segments differ in length.
    • Improves reliability of post-upgrade image identification, reducing failed or incorrect rename attempts.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

A conditional guard was added in the in-place upgrade test to normalize version strings before constructing the upgraded image name: if post_rhel_ver has length 3 and pre_rhel_ver has length 2, a "0" is appended to pre_rhel_ver. This ensures the subsequent string replacement for renaming the image uses matching-length version substrings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'IPU: update the name of upgraded image' directly reflects the main change: adjusting the upgraded image name through a guard that appends '0' to pre_rhel_ver when necessary for correct string replacement.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 529f635 and 2ade518.

📒 Files selected for processing (1)
  • qemu/tests/in_place_upgrade.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • qemu/tests/in_place_upgrade.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
qemu/tests/in_place_upgrade.py (1)

124-125: Replace generic exception handler with specific error handling.

The bare except Exception is too broad and will catch unexpected errors (AttributeError, KeyError, etc.), making debugging difficult. Catch only the exceptions you expect and re-raise or handle others appropriately.

             try:
                 image_name = params.objects("images")[0]
                 image_params = params.object_params(image_name)
                 image_path = params.get("images_base_dir", data_dir.get_data_dir())
                 old_name = storage.get_image_filename(image_params, image_path)
                 if len(post_rhel_ver) == 3 and len(pre_rhel_ver) == 2:
                     pre_rhel_ver += "0"
                 upgraded_name = old_name.replace(pre_rhel_ver, post_rhel_ver)
                 process.run(params.get("image_clone_command") % (old_name, upgraded_name))
-            except Exception as error:
+            except (OSError, subprocess.CalledProcessError) as error:
                 test.log.warning("Failed to rename upgraded image:%s", str(error))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 41d959a and 529f635.

📒 Files selected for processing (1)
  • qemu/tests/in_place_upgrade.py (1 hunks)
🔇 Additional comments (1)
qemu/tests/in_place_upgrade.py (1)

120-122: The review comment raises substantive concerns that are partially confirmed by code analysis. The version string normalization logic does rely on a very specific condition (len==3 and len==2) that is undocumented, and the str.replace() approach does pose a risk of unintended substring matches in image paths.

However, I cannot definitively verify whether this condition covers all supported upgrade scenarios (e.g., whether RHEL 7→8, 8→9, or other combinations produce different version string lengths). The test configuration files that would contain actual version examples were not found in the repository search.

Based on the available evidence:

  • Confirmed: The condition is specific to one length mismatch scenario and lacks documentation
  • Confirmed: Using str.replace() for version substitution could match unintended substrings
  • Unable to confirm: Whether other version length combinations exist that require handling
  • Unable to confirm: Whether the "0" padding is the only correct normalization needed

@MiriamDeng MiriamDeng changed the title IPU: update the name of upgrade image IPU: update the name of upgraded image Nov 18, 2025
@MiriamDeng
Copy link
Contributor Author

@PaulYuuu @fbq815 can you give a hand to review it ? Thanks

Copy link
Contributor

@fbq815 fbq815 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +120 to +122
if len(post_rhel_ver) == 3 and len(pre_rhel_ver) == 2:
pre_rhel_ver += "0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide commit message for this change?

And I cannot see any mapping between image name and guest variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks ! please help to review it again. @PaulYuuu

@MiriamDeng
Copy link
Contributor Author

Test results from rhel810-rhel980
(1/2) Host_RHEL.m10.u2.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: STARTED
(1/2) Host_RHEL.m10.u2.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.x86_64.io-github-autotest-qemu.unattended_install.cdrom.extra_cdrom_ks.default_install.aio_threads.q35: PASS (1590.93 s)
(2/2) Host_RHEL.m10.u2.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.x86_64.io-github-autotest-qemu.in_place_upgrade.without_rhsm_rhel8_to_rhel9.compose_install.q35: STARTED
(2/2) Host_RHEL.m10.u2.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.8.10.0.x86_64.io-github-autotest-qemu.in_place_upgrade.without_rhsm_rhel8_to_rhel9.compose_install.q35: PASS (1693.24 s)

@MiriamDeng
Copy link
Contributor Author

Test it from 9 to 10
(2/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-qemu.in_place_upgrade.without_rhsm.compose_install.q35: STARTED
(2/2) Host_RHEL.m10.u2.ovmf.qcow2.virtio_scsi.up.virtio_net.Guest.RHEL.9.8.0.x86_64.io-github-autotest-qemu.in_place_upgrade.without_rhsm.compose_install.q35: PASS (2313.59 s)

Make sure the name of image includes 3 numbers

Signed-off-by: Miriam Deng <[email protected]>
@MiriamDeng MiriamDeng force-pushed the fix_upgraded_image_name branch from 529f635 to 2ade518 Compare January 8, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants