Skip to content

fix: Use broad except clause for k8s config loading to avoid TypeError - #1064

Open
Asthenia0412 wants to merge 1 commit into
vllm-project:mainfrom
Asthenia0412:fix/k8s-config-exception-handling
Open

fix: Use broad except clause for k8s config loading to avoid TypeError#1064
Asthenia0412 wants to merge 1 commit into
vllm-project:mainfrom
Asthenia0412:fix/k8s-config-exception-handling

Conversation

@Asthenia0412

Copy link
Copy Markdown

Description

When initializing K8sPodIPServiceDiscovery or K8sServiceNameServiceDiscovery, 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.

Changes

Replaced except config.ConfigException: with except Exception: in both:

  • K8sPodIPServiceDiscovery.__init__()
  • K8sServiceNameServiceDiscovery.__init__()

This is more robust because:

  • ConfigException inherits from Exception, so the behavior is identical in normal cases
  • A broad except Exception handles edge cases where the exception class itself may not be a valid BaseException subclass
  • The intent of the code is to fall back to kube config when in-cluster config fails for any reason

Closes #660

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TypeError: k8 service discovery fail to load config

1 participant