vllm-project / vllm-project/production-stack

bug: TypeError: k8 service discovery fail to load config

Open
#660 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
2.6k
Forks
503
Avg merge
4d 17h
Merged PRs (30d)
8

Description

Describe the bug

I was in the process of unit testing the K8sPodIPServiceDiscovery class

I wanted to mock the config.load_incluster_config() so that it returns a config.ConfigException

Here is the error I got from python:

# Init kubernetes watcher
        try:
            config.load_incluster_config()
>       except config.ConfigException:
E       TypeError: catching classes that do not inherit from BaseException is not allowed
To Reproduce

When initializing K8sPodIPServiceDiscovery, mock the config.load_incluster_config() so that it returns a config.ConfigException

Expected behavior

It should not raise a TypeError

Additional context

The faulty code is:

        # Init kubernetes watcher
        try:
            config.load_incluster_config()
        except config.ConfigException:
            config.load_kube_config()

In https://github.com/vllm-project/production-stack/blob/main/src/vllm_router/service_discovery.py#L375 and https://github.com/vllm-project/production-stack/blob/main/src/vllm_router/service_discovery.py#L794

By the way, I see quite a bit of overlap between K8sServiceNameServiceDiscovery and K8sPodIPServiceDiscovery, it might be worth refactoring 😄

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/vllm_router/service_discovery.py at the two locations linked in the issue and inspect how K8sPodIPServiceDiscovery initializes its watcher. Reproduce the unit-test scenario around config.load_incluster_config() and compare it with the expected fallback behavior. Done means initialization no longer raises the reported TypeError and the relevant test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes, python
Domain
infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.