Repository navigation
feat(divide): optional deterministic key selection for sticky configuration (#8037) - #8212
Conversation
Aias00
left a comment
There was a problem hiding this comment.
Reviewed 0320e89. The optional key is extracted only when sticky configuration is active, preserves explicit binding precedence, and hashes the already admitted candidate set. Missing/blank keys retain the base algorithm; legacy IP hashing remains the default when no explicit hash key is supplied. P2C reservation is paired with the existing terminal release, while leastActive reserves in the common forwarding path.
Validation: 12 targeted Maven tests passed. An additional production Divide/cache/hash probe confirmed that keyed P2C requests stay in the selected Canary partition and release exactly once on error and cancellation; 64 keys retained their targets when candidate list order was reversed. Tests use controlled request/candidate fixtures rather than live upstream transports. The documented requirement for active signed-binding configuration and explicit binding precedence remains part of this delivery; no independent key-only enablement or topology-independent persistence is claimed.
Delivers the deterministic-key part of #8037 (the "configurable deterministic keys" phase), on top of the merged gateway-issued binding (#8098).
Problem
Sticky affinity so far covers explicit bindings only. The issue asks for deterministic key hashing as a separate mode: map a request carrying an operator-chosen key (a single header or cookie) onto the candidate set through a consistent hash ring, without creating a binding by itself. The existing
hashload balancer has a consistent ring but is pinned to the client IP, and its data carrier deliberately receives empty request collections to avoid copying headers per allocation.Change
StickySessionConfiggains an optional nestedkey(DeterministicKeyConfig:typeHEADER(default) /COOKIE,name). Absent configuration keeps the plain load-balancing behavior — nothing is extracted, nothing copied. The key lives inside the active sticky configuration, so it shares that single enablement surface rather than adding a second switch.DeterministicKeyExtractorreads exactly one named location and treats a missing or blank key as absent; the request falls back to the base algorithm.LoadBalanceDatacarries an optionalhashKey; thehashload balancer prefers it over the legacy client-ip key, which remains the default. Other algorithms ignore it.DividePlugin, the deterministic key applies only to binding-less requests (an explicit binding always wins) and is resolved from the candidate set that already passed canary and circuit-breaker admission — hashing can never bypass eligibility. With a P2C rule, a hash pick reserves the attempt exactly like a P2C selection does.STRICTis defined only for presented bindings, and the mapping is stable only while configuration, identities and candidate set are equivalent across gateway replicas. It is not topology-independent session persistence.Tests
COOKIEmode reads the cookie, not a same-named header; blank behaves like missing; no configured name means no extraction.keyparses from the rule-handle JSON (COOKIE+ name round-trip), so the operator-facing schema is exercised rather than only programmatic construction.expected 4 but was 1(everything lands on the client-ip node); removing the keyed pick's P2C reservation turns the accounting test red.Verification