Skip to content

Conversation

@MiriamDeng
Copy link
Contributor

@MiriamDeng MiriamDeng commented Nov 18, 2025

ID:4133

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed version string handling to ensure correct image renaming during the upgrade process.

ID:4133

Signed-off-by: Miriam Deng <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

The change modifies the version string handling logic in the in-place upgrade test module. A conditional guard is added to adjust the pre_rhel_ver variable by appending a "0" character when post_rhel_ver has a length of 3 characters and pre_rhel_ver has a length of 2 characters. This adjustment occurs before the upgraded image name is constructed, ensuring that subsequent string replacement operations use correctly formatted version strings during the image renaming process following an upgrade.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with straightforward conditional logic
  • Version string padding logic for a specific length mismatch scenario
  • No structural changes or complex dependencies

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'IPU: update the name of upgraded image' directly relates to the changeset, which adds a guard to adjust version strings for correct image renaming after upgrade.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

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.

1 participant