Commit b0e1401
CherryPicked: [cnv-4.20] [IUO]fix: Catch NotFoundError when pods are 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>1 parent 5afad3e commit b0e1401
1 file changed
+3
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
366 | 365 | | |
367 | 366 | | |
368 | 367 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 368 | + | |
| 369 | + | |
374 | 370 | | |
375 | 371 | | |
376 | 372 | | |
| |||
0 commit comments