fix: Use broad except clause for k8s config loading to avoid TypeError - #1064
Open
Asthenia0412 wants to merge 1 commit into
Open
fix: Use broad except clause for k8s config loading to avoid TypeError#1064Asthenia0412 wants to merge 1 commit into
Asthenia0412 wants to merge 1 commit into
Conversation
Catching config.ConfigException can raise a TypeError on some kubernetes client versions (e.g. 32.0.0) where ConfigException may not inherit from BaseException in certain environments. Using a broad except Exception clause is more robust and still correctly catches ConfigException since it inherits from Exception. Closes vllm-project#660 Signed-off-by: Asthenia <asthenia0412@gmail.com>
Asthenia0412
requested review from
ApostaC,
Shaoting-Feng,
YuhanLiu11 and
ruizhang0101
as code owners
August 29, 2026 09:53
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the Kubernetes configuration loading logic in src/vllm_router/service_discovery.py to catch all exceptions (Exception) instead of only config.ConfigException when attempting to load the in-cluster configuration, falling back to loading the local kube config. There are no review comments, and I have no additional feedback to provide.
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
When initializing
K8sPodIPServiceDiscoveryorK8sServiceNameServiceDiscovery, catchingconfig.ConfigExceptioncan raise aTypeErroron some kubernetes client versions (e.g. 32.0.0) whereConfigExceptionmay not inherit fromBaseExceptionin certain environments.Changes
Replaced
except config.ConfigException:withexcept Exception:in both:K8sPodIPServiceDiscovery.__init__()K8sServiceNameServiceDiscovery.__init__()This is more robust because:
ConfigExceptioninherits fromException, so the behavior is identical in normal casesexcept Exceptionhandles edge cases where the exception class itself may not be a valid BaseException subclassCloses #660