Add Redis-backed challenge coordination for cross-node machine setup#45
Add Redis-backed challenge coordination for cross-node machine setup#45Codex wants to merge 3 commits into
Conversation
|
The overall architecture is correct — using Redis pub/sub as the inter-node bus and local Go channels as the intra-node bus is exactly the right pattern. However there are several bugs and design issues that need to be addressed before this can be merged. 🔴 Critical: synchronous event dispatch blocks the entire subscriber goroutine
for msg := range sub.Channel() {
c.handleEvent(event) // blocking send inside
}
Fix: dispatch each event in its own goroutine: for msg := range sub.Channel() {
event := challengeEvent{}
if err := json.Unmarshal([]byte(msg.Payload), &event); err != nil {
log.Warn().Err(err).Msg("Failed to unmarshal challenge event")
continue
}
go c.handleEvent(event)
}🔴
|
|
@codex[agent] implement the changes requested in the comment above (PR reviewed) |
Implemented the requested fixes in 9e73fa2: listener now dispatches events asynchronously with non-blocking sends, ChallengeBus is DI-managed with fail-fast Redis init and proper Close(), remote wait state is simplified (no encryptedKey, duplicate registrations rejected), and session metadata drives cross-node routing. Added a Redis-backed cross-node challenge test to exercise the distributed path. Responder events now prioritize remote waits so mixed-node flows proceed without blocking. |
Challenge handshakes were kept in an in-memory map, preventing responses from being resolved when requests hit different nodes behind a load balancer.
ChallengeBus(Redis-based) to register challenges, publish/subscribe acceptance, challenger keys, and encrypted master keys with per-node channels; bus now initializes via DI, fails fast when Redis is configured but unavailable, and shuts down cleanly.NewMachineChallengeHandlerregisters challenges in Redis (with TTL) and records owner/responder nodes;MachineChallengeResponseHandlernow serves remote challenges by relaying through Redis with non-blocking dispatch, falling back to local in-memory flow when Redis is absent.REDIS_ADDR,REDIS_PASSWORD,REDIS_DB, andNODE_IDfor multi-node deployments; promoted Redis dependency to main requirements.Example flow (cross-node):
Original prompt