Migrate session manager to DataStorage with cross-pod restore#4479
Migrate session manager to DataStorage with cross-pod restore#4479
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4479 +/- ##
==========================================
+ Coverage 69.30% 69.32% +0.01%
==========================================
Files 502 502
Lines 51632 51655 +23
==========================================
+ Hits 35786 35808 +22
Misses 13077 13077
- Partials 2769 2770 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4acfc6e to
11869f0
Compare
11869f0 to
ad66b93
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates vMCP session persistence away from a direct *transportsession.Manager dependency by wiring session metadata storage through the DataStorage interface, enabling optional Redis-backed cross-pod session restore, and updates token-refresh singleflight tests to be deterministic.
Changes:
- Add
SessionStorageconfiguration to vMCP server config and constructDataStoragevia a newbuildSessionDataStoragehelper (local memory or Redis). - Add test-only synchronization hooks to
MonitoredTokenSourceto make singleflight-deduplication tests deterministic. - Plumb
SessionStoragefrom CLI config (commands.go) into the vMCP server configuration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/vmcp/server/server.go | Adds SessionStorage config and builds DataStorage (local/Redis) during server construction. |
| pkg/auth/monitored_token_source.go | Adds test hooks around singleflight entry to coordinate concurrent callers deterministically. |
| pkg/auth/monitored_token_source_test.go | Refactors the concurrency test to use a two-phase barrier and tighter call-count assertions. |
| cmd/vmcp/app/commands.go | Passes SessionStorage from CLI config into the server config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ad66b93 to
47c3651
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add SessionStorage *vmcpconfig.SessionStorageConfig to vmcpserver.Config and introduce buildSessionDataStorage: - provider nil/"memory": uses LocalSessionDataStorage (default, unchanged) - provider "redis": constructs RedisSessionDataStorage with address, DB, and key prefix from SessionStorageConfig; password from THV_SESSION_REDIS_PASSWORD; empty KeyPrefix defaults to "thv:vmcp:session:"; unknown provider values return an error - Pass cfg.SessionStorage from commands.go so the operator-provided Redis config reaches the server Related-to: #4220
8dd7805 to
c56ee00
Compare
Summary
Follow-on to #4464 (merged). That PR landed the core DataStorage migration —
RestorableCache,sessionmanager.Managerrewrite,MultiSessionGetterinterface, andRestoreSession. This PR adds the remaining piece: Redis session storage wiring.Redis session storage wiring
Add
SessionStorage *vmcpconfig.SessionStorageConfigtovmcpserver.Configand introducebuildSessionDataStorage:SessionStorageis nil, provider is"memory", or provider is empty/unset, local in-process storage is used (default behaviour unchanged)."redis", aRedisSessionDataStorageis constructed (password fromTHV_SESSION_REDIS_PASSWORD) — enabling cross-pod session persistence."Redis"will not silently fall back to local storage)."memory".Pass
cfg.SessionStoragefromcommands.goso the operator-provided Redis config reaches the server.Fixes #4220
Type of change
Test plan
task test)task test-e2e)task lint-fix)Does this introduce a user-facing change?
No new user-facing changes beyond #4464. The Redis wiring is a configuration opt-in (operator sets
sessionStorage.provider: redis); default behaviour (local in-process storage) is unchanged.