Repository navigation
feat(kv-router): one session affinity config and validator, mode on every host - #87
Draft
ishandhanani wants to merge 1 commit into
Conversation
ishandhanani
had a problem deploying
to
external_collaborator
October 6, 2026 09:28 — with
GitHub Actions
Failure
ishandhanani
added this pull request to stack #89
October 6, 2026 20:45
…very host `SessionAffinityConfig` is the one session-affinity configuration and gains the one validator: `validate` checks the TTL range and the limits before a table starts, and `ttl_from_secs_f64` is the one range check for a TTL given in seconds. The four copies of the TTL check (the table, the selection service builder, the Python bindings, and the frontend's argument parser) and the EPP's separate range attribute all go through it. The bindings export `validate_session_affinity_ttl_secs` so `dynamo.frontend`'s argument parser reports its own flag with the router's check instead of a copied constant. The session-affinity mode (`hard` or `soft`, `hard` by default) is now settable on the standalone selection service (`--session-affinity-mode`, `SelectionService(session_affinity_mode=...)`) and the EPP (`DYN_EPP_SESSION_AFFINITY_MODE`), which were always `hard`. Docs: the frontend's mode table describes the pin rule (a hard binding limits selection while eligible, re-binds when its worker leaves, and is rejected before dispatch when the request's own constraints exclude it; a full table routes without affinity), the standalone service and EPP reference pages gain the mode setting, the custom-policy guide describes hard affinity as a narrowed candidate set rather than an exact-target path, and the replication subjects and topics are documented with their one-release dual-publish window. Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
ishandhanani
force-pushed
the
idhanani/session-affinity-unification-p6
branch
from
October 6, 2026 21:42
53f376c to
be3de21
Compare
ishandhanani
had a problem deploying
to
external_collaborator
October 6, 2026 21:42 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Last PR of the session-affinity unification stack (base:
idhanani/session-affinity-unification-p5). One configuration and one validator for every host, the session-affinity mode on the two hosts that lacked it, and the docs.Config and validator
SessionAffinityConfig(TTL, mode, entry limit, session-id limit) is the one configuration. It gains the one validator:validatechecks the TTL range and the limits before a table starts, andttl_from_secs_f64is the one range check for a TTL given in seconds (fractional allowed, non-finite rejected). The copies it replaces:SessionAffinity::validate_ttl(affinity.rs:209)SessionAffinityConfig::validate, run bywith_configSelectionServiceBuilder::buildrange check (service.rs:152)config.validate()session_affinity_ttl_from_secs(kv.rs:637-650)ttl_from_secs_f64, naming the Python parameterfrontend_args.pyhardcoded range (frontend_args.py:144)dynamo._core.validate_session_affinity_ttl_secs(ttl, "--router-session-affinity-ttl-secs")#[validate(range(...))]attributeSessionAffinityConfig::ttl_from_secs_f64inSelector::new(invalid session affinity TTLcontext kept)Error messages seen by users are unchanged where tests pin them (
session_affinity_ttl_secs must be between 1 and 31536000on the bindings,--router-session-affinity-ttl-secs must be between 1 and 31536000on the frontend,session affinity TTLon the EPP).Mode setting
hardorsoft,hardby default (unchanged behavior when unset):--session-affinity-mode(python -m dynamo.select_service),SelectionService(session_affinity_mode=...),SelectionServiceBuilder::session_affinity_mode,SelectionServiceConfig::session_affinity_mode.DYN_EPP_SESSION_AFFINITY_MODE.--router-session-affinity-modealready existed; its reference page gains the missingParamField.Docs
--session-affinity-mode, the v2 topic, hard/soft semantics forsession_id.DYN_EPP_SESSION_AFFINITY_MODE.--router-session-affinity-mode.lib/kv-router/src/services/selection/affinity/README.md: configuration section.Behavior changes
None by default. The EPP's TTL error now surfaces when the selector starts rather than when the config is parsed (both at startup).
Validation
Run with
RUSTC_WRAPPER=and a per-worktreeCARGO_TARGET_DIR.cargo test -p dynamo-kv-router --features standalone-selection --libcargo test -p dynamo-ext-proccargo test -p dynamo-llm --lib kv_routercargo test -p dynamo-llm --lib session_affinitycargo test -p dynamo-custom-policy-builtin -p dynamo-mockercargo clippy(kv-router withstandalone-selection,bench; llm, ext-proc, builtin, mocker)--all-targets -- -D warningscargo clippy --manifest-path lib/bindings/python/Cargo.toml --features select-service -- -D warningscargo fmt --all -- --checkpython3 -m py_compile components/src/dynamo/frontend/frontend_args.py;validate_session_affinity_ttl_secs(x, "--router-session-affinity-ttl-secs")for 0, 0.5, NaN, 31536001--router-session-affinity-ttl-secs must be between 1 and 31536000maturin develop --uv --features select-servicein<worktree>/.venv, thenpytest lib/bindings/python/tests/test_kv_bindings.py -k "affinity or session"dynamo.select_serviceCLI rejection cases)pytest lib/bindings/python/tests/test_kv_bindings.py(whole file)pytest tests/router/test_router_e2e_with_mockers.py -k session_affinity(etcdv3.5.21,nats-serverv2.10.26,nats-pyin the venv)test_mocker_session_affinity[etcd],[file],test_disagg_per_role_session_affinitypytest tests/router/test_router_e2e_with_mockers.py(whole file, 56 tests)Flaky on CI: TCP round-robinskip marker). First pass with aselect-service-only build failed 5 tests on missing build features (dynamo.indexerneedskv-indexer; the AIS perf model needsais-forward-pass); rebuilt withselect-service,kv-indexer,ais-forward-pass(a subset of the shipped wheel's feature set) and those 5 passed in 90 sRelated Issues