CherryPicked: [cnv-4.18] [IUO]fix: Catch NotFoundError when pods are deleted during iteration#4431
Conversation
…deleted during iteration … (RedHatQE#4376) Cherry pick of (RedHatQE#3676) Same problematic code in 4.20, 4.19, 4.18 too Replace invalid exception handling that attempted to compare ex.reason (string) with ResourceNotFoundError (exception class), causing TypeError. When pod.instance.metadata is accessed for a deleted pod, the kubernetes dynamic client raises NotFoundError (which inherits from ApiException). The original code had invalid syntax trying to compare the HTTP reason string with an exception class. Changed from: except ApiException as ex: if ex.reason == ResourceNotFoundError: To: except NotFoundError: This correctly catches the NotFoundError when a pod is deleted during iteration and gracefully ignores it, following the established pattern in the codebase (tests/infrastructure/conftest.py). Also removed unused imports: ApiException and ResourceNotFoundError. Fixes test failures: - test_change_subscription_on_selected_node_before_workload - test_infrastructure_components_selection_change_allowed_after_workloads - N/A N/A https://redhat.atlassian.net/browse/CNV-83861 Signed-off-by: Alex <albarker@redhat.com> Co-authored-by: Ramon Lobillo Mateos <62110535+rlobillo@users.noreply.github.com> Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com> Signed-off-by: Alex <albarker@redhat.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4431 published |
|
/verified 4.18 |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Your deliverable: Test Execution Plan
Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL: Before setting "Run smoke tests: True", you MUST use shell scripts to: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1552 🏁 Script executed: Length of output: 841 🏁 Script executed: Length of output: 40 🏁 Script executed: Length of output: 1735 🧠 Learnings used |
|
/approve |
|
Successfully removed PR tag: quay.io/openshift-cnv/openshift-virtualization-tests:pr-4431. |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:cnv-4.18 published |
4.21 cherry pick (#4376)
Cherry pick of (#3676)
Same problematic code in 4.20, 4.19, 4.18 too
Replace invalid exception handling that attempted to compare ex.reason (string) with ResourceNotFoundError (exception class), causing TypeError.
When pod.instance.metadata is accessed for a deleted pod, the kubernetes dynamic client raises NotFoundError (which inherits from ApiException). The original code had invalid syntax trying to compare the HTTP reason string with an exception class.
Changed from:
except ApiException as ex:
if ex.reason == ResourceNotFoundError:
To:
except NotFoundError:
This correctly catches the NotFoundError when a pod is deleted during iteration and gracefully ignores it, following the established pattern in the codebase (tests/infrastructure/conftest.py).
Also removed unused imports: ApiException and ResourceNotFoundError. Fixes test failures:
N/A
N/A
https://redhat.atlassian.net/browse/CNV-83861
Short description:
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket: