fix: replace bare except with Exception handler in Kubernetes client initialization#1265
Open
parth-agrawall wants to merge 1 commit into
Open
Conversation
…init The bare except clause in the Kubernetes client initialization block caused a NameError crash when initialization failed. If KrknKubernetes() raised an exception before kubecli was assigned, the except handler attempted to call kubecli.initialize_clients(None) on an undefined variable, masking the original error entirely. Replaced the bare except with except Exception as e to: - Log the actual initialization error for visibility - Initialize both kubecli and ocpcli with None kubeconfig as fallback so subsequent code referencing these variables does not crash - Avoid catching SystemExit and KeyboardInterrupt unintentionally Fixes krkn-chaos#1264 Signed-off-by: Parth Agrawal <parth.agrawal4002@gmail.com>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
Collaborator
|
/agentic-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Kubernetes client initialization block in
run_kraken.pyused a bareexcept:clause that caused aNameErrorcrash whenever initialization failed, completely hiding the original error from the user.Root Cause
If
KrknKubernetes()raised an exception beforekubecliwas assigned, the except handler immediately tried to callkubecli.initialize_clients(None)on an undefined variable. This replaced the real error with an unrelatedNameError. The bareexcept:also unintentionally caughtSystemExitandKeyboardInterrupt.Changes
run_kraken.py: Replaced bareexcept:withexcept Exception as elogging.error()to surface the actual initialization failurekubecliandocpcliwithkubeconfig_path=Noneas fallback so subsequent code referencing these variables does not crash withNameErrorTesting
kubecliandocpcliare always defined after the try/except blockSystemExitandKeyboardInterruptare no longer swallowedRelated Issue
Closes #1264
Signed-off-by: Parth Agrawal parth.agrawal4002@gmail.com