Skip to content

[Bugfix][Router] Let the dynamic config file set startup-only flags - #1235

Open
Mazyod wants to merge 2 commits into
vllm-project:mainfrom
Mazyod:fix/dynamic-config-startup-flags
Open

Mazyod wants to merge 2 commits into
vllm-project:mainfrom
Mazyod:fix/dynamic-config-startup-flags

Conversation

@Mazyod

@Mazyod Mazyod commented Nov 24, 2026

Copy link
Copy Markdown

FIX #1232

The dynamic config file can hold any router flag at startup, but the watcher built DynamicRouterConfig(**config) from it. Any startup-only key (for example log_stats) then raised TypeError on every tick, which silently disabled hot reload.

from_yaml and from_json now classify the file's keys:

  • Reloadable fields are applied.
  • Router flags that aren't fields are ignored and debug-logged. They are recognized from the same argparse parser used at startup, so parse_args now delegates to a new build_parser.
  • Any other key raises ValueError, so the watcher keeps the running configuration instead of silently resetting a misspelled field to its default.

The k8s_* default mismatch described in #1232 is deliberately left out to keep this focused. Happy to add it here or in a follow-up.

Testing:

  • A YAML file with log_stats and engine_stats_interval loads, and a JSON file with the typo callback is rejected. Both tests fail on main with TypeError and pass with this change.
  • All 285 router tests pass on Python 3.12, and pre-commit passes.
  • Our production fork (Mazyod/production-stack) has used the same classification since July 2026.

  • Make sure the code changes pass the pre-commit checks.
  • Sign-off your commit by using -s when doing git commit
  • Try to classify PRs for easy understanding of the type of changes, such as [Bugfix], [Feat], and [CI].

🤖 Generated with Claude Code

https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ

At startup, --dynamic-config-yaml/--dynamic-config-json apply every key in
the file as an argparse default, so the file can hold any router flag, such
as log_stats. The watcher then builds DynamicRouterConfig(**config) from the
same file every 10 seconds. That constructor raises TypeError for any key
that is not a reloadable field, and the watcher only logs a warning. So a
file with one startup-only flag silently disables hot reload for every
field.

Build the config from the file's keys instead:
- Reloadable fields are applied.
- Router flags that are not fields are ignored (debug-logged).
- Any other key is most likely a typo and raises ValueError, so the watcher
  keeps the running configuration rather than resetting the misspelled
  field to its default.
Flags are recognized from the same argparse parser used at startup;
parse_args now delegates to build_parser for this.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ
Signed-off-by: Mazyad Alabduljaleel <[email protected]>

@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 refactors the dynamic configuration loading to handle startup-only flags gracefully and reject unknown keys during reloads. It extracts the command-line parser creation into a standalone build_parser function to identify valid flags, introduces from_config_dict to filter these flags, and adds corresponding unit tests. Feedback is provided to specify encoding='utf-8' when opening the JSON configuration file to avoid potential UnicodeDecodeError issues on platforms where the default encoding is not UTF-8.

@staticmethod
def from_json(json_path: str) -> "DynamicRouterConfig":
with open(json_path, "r") as f:
config = json.load(f)

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.

medium

When opening the JSON configuration file, the encoding parameter is not specified. On platforms where the default system encoding is not UTF-8 (such as Windows), this can lead to UnicodeDecodeError if the file contains non-ASCII characters.\n\nTo ensure consistency with other file-loading methods in the codebase (e.g., in parser.py and yaml_utils.py), please specify encoding=\"utf-8\" when opening the file:\n\npython\n with open(json_path, \"r\", encoding=\"utf-8\") as f:\n

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Applied in 65d25c6: the JSON config is now read as UTF-8, like the YAML loader and parser.py.

Address review feedback: match the YAML loader and parser.py, which already open config files as UTF-8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EkWp1KKx8oCX8JA3mXdkVJ
Signed-off-by: Mazyad Alabduljaleel <[email protected]>
@Mazyod

Mazyod commented Nov 24, 2026

Copy link
Copy Markdown
Author

A note on #1167, which also touches dynamic_config.py: the two complement each other. #1167 makes the routing settings reloadable fields, and this PR lets the file carry the remaining startup-only flags. I merged both onto main (405a2fa): no conflicts, and all router tests pass (285 passed, 1 skipped). Whichever lands first, the other should still apply cleanly.

This branch has not been deployed

No deployments
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: a startup-only flag in the dynamic config file makes every reload fail with TypeError

1 participant