-
Notifications
You must be signed in to change notification settings - Fork 259
libvirt.py: Add wait time for mk_label check #4288
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
base: master
Are you sure you want to change the base?
libvirt.py: Add wait time for mk_label check #4288
Conversation
WalkthroughThe change modifies disk label creation during pool pre-setup in Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this 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 (2)
virttest/utils_test/libvirt.py (2)
1071-1076: Refine exception handling for better debugging.The nested function catches a bare
Exception, which is overly broad and could mask unexpected errors. Additionally, the exception variableeis assigned but never used, making debugging more difficult.Consider these improvements:
def mk_label_wait(): try: mk_label(device_name, disk_label) - except Exception as e: + except process.CmdError as e: + LOG.debug("mk_label failed: %s. Retrying...", e) return False return TrueIf you need to catch multiple exception types, use a tuple:
except (process.CmdError, OSError) as e:Based on the
mk_labelfunction at line 833, it callsprocess.run()which raisesprocess.CmdErroron failure, so catching that specific exception type would be more appropriate.
1077-1078: Check the return value from wait_for to handle timeout scenarios.The
wait_forfunction returnsNoneif the operation times out, but this return value is not being checked. This could lead to the pool setup continuing even when the disk label wasn't successfully created, potentially causing failures later in the process.Apply this diff to handle the timeout case:
- utils_misc.wait_for(mk_label_wait, 10, text="Label not created \ - as device is unavailable. Retrying...") + result = utils_misc.wait_for( + mk_label_wait, 10, + text="Label not created as device is unavailable. Retrying..." + ) + if not result: + raise exceptions.TestError( + "Failed to create label on %s after 10 seconds" % device_name + )This ensures that if the device doesn't become available within the timeout period, the test fails with a clear error message rather than continuing with an unlabeled disk.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
virttest/utils_test/libvirt.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
virttest/utils_test/libvirt.py (1)
virttest/utils_misc.py (2)
wait_for(557-592)wait_for(4186-4234)
🪛 Ruff (0.14.8)
virttest/utils_test/libvirt.py
1074-1074: Do not catch blind exception: Exception
(BLE001)
1074-1074: Local variable e is assigned to but never used
Remove assignment to unused variable e
(F841)
|
PR notes Job log after changes: |
When the script tries to label a newly created partition, it might fail saying the partition is not available, as there is a slight delay between defining the partition and it being available in the block devices list. This PR helps to fix that by adding a wait statement with a 10 second timeout. Signed-off-by: Aniket Sahu <asahu1x@linux.ibm.com>
2872a37 to
e943377
Compare
misanjumn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
When the script tries to label a newly created partition, it might fail saying the partition is not available, as there is a slight delay between defining the partition and it being available in the block devices list. This PR helps to fix that by adding a wait statement with a 10 second timeout.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.