feat(router): support max_instance_failover_reroute_attempts in dynamic config#984
feat(router): support max_instance_failover_reroute_attempts in dynamic config#984nejch wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the max_instance_failover_reroute_attempts configuration to the dynamic router config, allowing users to specify the number of reroute attempts to other instances per failed request. It includes corresponding documentation updates and unit tests. The feedback highlights potential TypeError and UnboundLocalError issues if max_instance_failover_reroute_attempts is parsed as None or configured with a negative value. It is recommended to safely default None values to 0 and ensure the value is non-negative when parsing arguments and reconfiguring the routing logic.
| # Routing logic configurations | ||
| routing_logic=args.routing_logic, | ||
| session_key=args.session_key, | ||
| max_instance_failover_reroute_attempts=args.max_instance_failover_reroute_attempts, |
There was a problem hiding this comment.
If args.max_instance_failover_reroute_attempts is None (e.g., if the CLI flag is not set or defaults to None), passing it directly will set the dataclass field to None. This bypasses the default value of 0 and can lead to a TypeError when routing requests (e.g., None + 1 in request.py). Additionally, negative values should be prevented to avoid an UnboundLocalError in the request routing loop. We should safely default None to 0 and ensure the value is non-negative.
| max_instance_failover_reroute_attempts=args.max_instance_failover_reroute_attempts, | |
| max_instance_failover_reroute_attempts=max(0, args.max_instance_failover_reroute_attempts) if args.max_instance_failover_reroute_attempts is not None else 0, |
| config.routing_logic, session_key=config.session_key | ||
| config.routing_logic, | ||
| session_key=config.session_key, | ||
| max_instance_failover_reroute_attempts=config.max_instance_failover_reroute_attempts, |
There was a problem hiding this comment.
If config.max_instance_failover_reroute_attempts is explicitly configured as None (or null in YAML/JSON), passing it directly to reconfigure_routing_logic will set the router's attempts to None, causing a TypeError during request routing. Additionally, we should guard against negative values to prevent an UnboundLocalError in the request routing loop. Let's ensure it defaults to 0 and is non-negative.
| max_instance_failover_reroute_attempts=config.max_instance_failover_reroute_attempts, | |
| max_instance_failover_reroute_attempts=max(0, config.max_instance_failover_reroute_attempts) if config.max_instance_failover_reroute_attempts is not None else 0, |
…ic config Signed-off-by: Nejc Habjan <nejc.habjan@siemens.com>
a237358 to
59cf91b
Compare
Previously the number of instance failover reroute attempts could only be set via the --max-instance-failover-reroute-attempts CLI flag. This PR exposes it as a dynamic config (YAML/JSON) field so it can be reconfigured at runtime without restarting the router.
-swhen doinggit commit[Bugfix],[Feat], and[CI].Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]for bug fixes.[CI/Build]for build or continuous integration improvements.[Doc]for documentation fixes and improvements.[Feat]for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]for changes to thevllm_router(e.g., routing algorithm, router observability, etc.).[Misc]for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
pre-committo format your code. SeeREADME.mdfor installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:header which certifies agreement with the terms of the DCO.Using
-swithgit commitwill automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.