Visitar URL original
[Misc] gateway: deduplicate session affinity header constants by RinZ27 · Pull Request #2600 · vllm-project/aibrix · GitHub
Skip to content

[Misc] gateway: deduplicate session affinity header constants - #2600

Closed
RinZ27 wants to merge 2 commits into
vllm-project:mainfrom
RinZ27:fix/dedup-session-affinity-header-constants
Closed

RinZ27 wants to merge 2 commits into
vllm-project:mainfrom
RinZ27:fix/dedup-session-affinity-header-constants

Conversation

@RinZ27

@RinZ27 RinZ27 commented Aug 21, 2026 •

Copy link
Copy Markdown

Pull Request Description

The session affinity header names were defined in two separate places:

  • pkg/plugins/gateway/types.go: HeaderSessionID and HeaderSessionKey
  • pkg/plugins/gateway/algorithms/simple_session_affinity.go: local sessionIDHeader / sessionKeyHeader (copies of the same strings)

There was already a NOTE comment warning that the two copies had to stay in sync manually. If one side ever changed without updating the other, the session-affinity router would silently parse the wrong header — breaking sticky or session-key routing.

Moved the canonical values into pkg/types (which the algorithm package already imports), so both places reference a single definition. gateway/types.go re-exports them as typed aliases for backward compatibility with existing callers.

Related Issues

Resolves: #2597


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

@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 consolidates the session affinity header constants (HeaderSessionID and HeaderSessionKey) into a central pkg/types package, updating their references across the gateway plugins, routing algorithms, and tests to prevent duplicate definitions and potential routing mismatches. There are no review comments, and I have no additional feedback to provide.

@RinZ27 RinZ27 changed the title gateway: deduplicate session affinity header constants [Misc] gateway: deduplicate session affinity header constants Aug 21, 2026
Move HeaderSessionID and HeaderSessionKey into pkg/types so both
the gateway plugin and the session-affinity routing algorithm share
a single source of truth.

Previously the strings were defined twice — once in
pkg/plugins/gateway/types.go and again as local constants in
pkg/plugins/gateway/algorithms/simple_session_affinity.go — with
a manual NOTE comment warning that the two copies must stay in sync.
If one side changed without updating the other, header parsing in the
session-affinity router would silently disagree with the rest of the
gateway, breaking sticky routing.

Changes:
- Add HeaderSessionID and HeaderSessionKey to pkg/types/router_context.go
- gateway/types.go re-exports them via typed aliases (no value duplication)
- simple_session_affinity.go and its test file now reference
  types.HeaderSessionID / types.HeaderSessionKey directly

Fixes vllm-project#2597

Signed-off-by: RinZ27 <222222878+RinZ27@users.noreply.github.com>
@RinZ27
RinZ27 force-pushed the fix/dedup-session-affinity-header-constants branch from cc17462 to 8c39a02 Compare August 21, 2026 14:51
@varungup90

Copy link
Copy Markdown
Collaborator

pkg/plugins/gateway/algorithms/simple_session_affinity.go:35

Minor gofmt alignment issue in the const block. Removing the longer sessionIDHeader/sessionKeyHeader constants left extra space before the = on maxSessionKeyLen.

Running gofmt -w pkg/plugins/gateway/algorithms/simple_session_affinity.go will fix the padding and allow make lint-all to pass.

@RinZ27

RinZ27 commented Aug 24, 2026 •

Copy link
Copy Markdown
Author

Closing this PR because another contributor already solved the exact same issue (#2597) in PR #2599

@RinZ27 RinZ27 closed this Aug 24, 2026
@RinZ27
RinZ27 deleted the fix/dedup-session-affinity-header-constants branch August 24, 2026 14:05
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.

[Cleanup] Avoid duplicated session affinity header constants

2 participants