feat(clusters): add real-time cluster log streaming#182
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds real-time cluster log streaming capabilities to the CLI, enabling users to monitor Kubernetes events during cluster deployment and troubleshoot issues more effectively. The implementation introduces a new streaming infrastructure to handle NDJSON responses from the backend API.
Changes:
- Added
StreamingGetRequestCommandbase class in shared HTTP infrastructure to handle NDJSON streaming with graceful error handling for malformed lines and connection drops - Added
exls clusters logscommand with--jsonflag for raw NDJSON output - Added
--follow/-fflag toexls clusters deploycommand to automatically tail logs after deployment starts
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| exls/shared/adapters/http/commands.py | Adds StreamingGetRequestCommand base class for NDJSON streaming with error handling |
| exls/clusters/core/domain.py | Adds ClusterEvent and ClusterEventInvolvedObject domain models |
| exls/clusters/core/service.py | Adds stream_cluster_logs service method with error handling decorator |
| exls/clusters/core/ports/operations.py | Adds stream_logs port method to operations interface |
| exls/clusters/adapters/adapter.py | Implements stream_logs in adapter layer |
| exls/clusters/adapters/gateway/gateway.py | Adds abstract stream_logs method to gateway interface |
| exls/clusters/adapters/gateway/sdk/sdk.py | Implements streaming in SDK gateway with proper resource cleanup |
| exls/clusters/adapters/gateway/sdk/commands.py | Adds StreamClusterLogsSdkCommand using streaming infrastructure |
| exls/clusters/adapters/bundle.py | Updates bundle to pass base_url and access_token to gateway and provides log renderer |
| exls/clusters/adapters/ui/display/log_renderer.py | Adds ClusterLogRenderer for formatted console output |
| exls/clusters/app.py | Adds logs command and --follow flag with shared streaming helper |
| tests/unit/shared/test_streaming_command.py | Comprehensive tests for streaming command error handling and edge cases |
| tests/unit/clusters/test_log_renderer.py | Tests for log rendering including multiline message handling |
| tests/unit/clusters/test_cluster_event_domain.py | Tests for domain model validation and serialization |
| tests/unit/clusters/test_clusters_app.py | Tests for iterator cleanup on normal exit and keyboard interrupt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1e380a6 to
6fb7874
Compare
…t into the shared display module
|
Nice feature! Perfect structural Implementation for the I’ve refactored the display logic to better align with the architecture:
This separation keeps our domain logic pure and our shared display logic consistent across the domains. |
Description
This PR adds the possibility to stream cluster deployment and deletion events from the API.
exls clusters logs <CLUSTER_NAME_OR_ID>command to stream Kubernetes events in real-time via theGET /cluster/{cluster_id}/logsNDJSON endpoint, giving users visibility into what is happening during cluster provisioning and helping them spot issues early--follow / -fflag onexls clusters deployto automatically tail logs after deployment starts--jsonflag onlogscommand for raw NDJSON outputNotes for Reviewers
The generated SDK cannot handle NDJSON streams, so this introduces
StreamingGetRequestCommandin the shared HTTP infrastructure usingrequestswithstream=True+iter_lines(). Malformed lines and mid-stream connection drops are handled gracefully.