feat(cluster): Add peer server support with invite+accept handshake#85
Merged
feat(cluster): Add peer server support with invite+accept handshake#85
Conversation
Code Review SummaryThis PR introduces a hub-and-spoke clustering system. It handles peer invitation, key exchange, and health monitoring effectively. The code is well-structured and highly tested. 🚀 Key Improvements
💡 Minor Suggestions
|
Implement hub-and-spoke cluster architecture allowing multiple Flatrun agents to cooperate as peers. Peering requires mutual agreement via a one-time invite token with 1-hour expiry. New cluster package with SQLite storage, encrypted API key management, health check loop, fan-out aggregation, and transparent proxy. Includes API routes for invite/accept/exchange flow, peer management, and cross-server deployment/stats aggregation. Signed-off-by: nfebe <fenn25.fn@gmail.com>
Test was flaky due to non-deterministic map iteration order when extracting bind mounts from Docker service configs. Signed-off-by: nfebe <fenn25.fn@gmail.com>
5de99bf to
4a6f83a
Compare
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.
Implement hub-and-spoke cluster architecture allowing multiple Flatrun agents to cooperate as peers. Peering requires mutual agreement via a one-time invite token exchange. API keys are auto-generated and encrypted at rest using AES-GCM derived from the JWT secret.
New cluster package provides SQLite storage for peers/invites, an HTTP client for peer communication, a manager with health check goroutines, and fan-out aggregation for cross-server queries.
Adds 9 API endpoints for cluster management including invite creation, key exchange, peer listing/removal, transparent proxy, and aggregated deployments/stats. Includes 48 tests covering unit, integration, and a full two-server peering E2E flow.