Skip to content

Commit baced1f

Browse files
authored
Merge pull request #9 from ecmwf-projects/feature/cachedstream
Possibility of streaming after files are retrieved on a filesystem available to the server.
2 parents 9e7438d + 86c9a20 commit baced1f

38 files changed

Lines changed: 6189 additions & 26 deletions

.github/workflows/on-push.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ jobs:
143143
integration-tests:
144144
needs: [combine-environments, unit-tests]
145145
if: |
146-
success() && true
146+
success()
147147
runs-on: ubuntu-latest
148148

149149
strategy:
150150
matrix:
151151
include:
152-
- python-version: '3.6'
152+
- python-version: '3.11'
153153
extra: -integration
154154

155155
steps:
@@ -173,9 +173,9 @@ jobs:
173173
- name: Install package
174174
run: |
175175
python -m pip install --no-deps -e .
176-
- name: Run tests
176+
- name: Run integration tests
177177
run: |
178-
make unit-tests COV_REPORT=xml
178+
make integration-tests COV_REPORT=xml
179179
180180
distribution:
181181
runs-on: ubuntu-latest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,5 +468,9 @@ $RECYCLE.BIN/
468468

469469
# Windows shortcuts
470470
*.lnk
471+
create/*
471472

472473
# End of https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks,vim,visualstudiocode,pycharm,emacs,linux,macos,windows
474+
475+
# Hide create environment files
476+
create

CHANGELOG.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Changelog
2+
3+
All notable changes to cads-mars-server will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.4.0] - 2026-06-16
9+
10+
### Added
11+
12+
- New stream-oriented server mode via `server_cache_and_stream.py`
13+
- New stream server command support for serving cached and streamed MARS output
14+
- Additional unit and integration tests for server and client components
15+
16+
### Changed
17+
18+
- Improved stream server configuration for shared volumes and cache folder settings
19+
- Updated handler wiring to use configuration-driven shared root, shares, and cache folder values
20+
- Added default `PADDING` handling in MARS request execution path
21+
- Enabled automatic splitting of streamed MARS output by date boundaries
22+
23+
### Fixed
24+
25+
- Standardized shared root and cache folder configuration key handling
26+
- Fixed missing dependency declarations needed by runtime/test workflows
27+
- Corrected streaming HTTP response chunking and termination behavior
28+
- Improved datadir resolution logging for better troubleshooting
29+
30+
## [0.3.0] - 2026-02-10
31+
32+
### Added
33+
34+
#### WebSocket Client/Server Architecture
35+
36+
**Why WebSocket instead of HTTP?**
37+
38+
The new WebSocket-based architecture provides significant advantages over traditional HTTP request/polling patterns:
39+
40+
- **Real-time bidirectional communication**: Logs stream from server to client as they occur, eliminating polling overhead
41+
- **Long-running request support**: Single persistent connection handles jobs that may run for minutes or hours
42+
- **Efficient resource usage**: No repeated polling requests consuming server resources and network bandwidth
43+
- **Interactive control**: Client can send commands (e.g., kill) to running jobs without establishing new connections
44+
- **Lower latency**: Immediate notification of job completion, errors, or status changes
45+
- **Simplified connection management**: Automatic reconnection and failover built into the protocol
46+
47+
Traditional HTTP polling would require:
48+
49+
- Periodic status check requests (wasted bandwidth, server load)
50+
- Delayed notifications (polling interval limits responsiveness)
51+
- Complex state management on server for status queries
52+
- Additional API endpoints for job control
53+
54+
WebSocket provides a natural fit for the workflow: submit job → stream logs → receive result.
55+
56+
______________________________________________________________________
57+
58+
#### Core Features
59+
60+
- **WebSocket-based MARS client** (`ws_client.py`, `ws_server.py`) for shared filesystem deployments
61+
62+
- Asynchronous request handling with server-side job monitoring
63+
- Connection pooling with automatic failover across multiple servers
64+
- Real-time log streaming from MARS processes to clients
65+
- Bidirectional communication for job control (kill, heartbeat)
66+
- Configurable retry logic and connection timeouts
67+
68+
- **Modal client selection via `USE_SHARES` configuration**
69+
70+
- `MARS_USE_SHARES=false` (default): Traditional pipe-based client (fully backward compatible)
71+
- `MARS_USE_SHARES=true`: WebSocket client for shared filesystem deployments
72+
- Configuration via environment variable or YAML file (`/etc/cads-mars-server.yaml`)
73+
74+
- **Client-side log filtering** ([LOG_FILTERING.md](docs/LOG_FILTERING.md))
75+
76+
- Reduces noise from verbose MARS output
77+
- Pattern-based filtering (errors, warnings, progress indicators)
78+
- Message deduplication for repeated lines
79+
- Injectable custom log handlers:
80+
- Parse logs with custom logic
81+
- Raise exceptions to abort requests on specific error conditions
82+
- Send real-time commands to server (e.g., kill on timeout)
83+
- Integrate with external monitoring systems
84+
- Controlled via `CLIENT_FILTER_LOGS` config (default: enabled)
85+
86+
- **CephFS health diagnostics** ([CEPHFS_ARCHITECTURE.md](docs/CEPHFS_ARCHITECTURE.md))
87+
88+
- `check-cephfs-health` console script for diagnosing filesystem issues
89+
- Documentation of CephFS architecture (MON/MDS/OSD components)
90+
- Startup health checks with warnings for detected issues
91+
92+
### Fixed
93+
94+
- **Process group management for WebSocket server**
95+
96+
- Properly terminates entire process groups (parent + bash + MARS + children)
97+
- Prevents orphaned processes during restarts or crashes
98+
- Graceful shutdown with SIGTERM/SIGINT signal handlers
99+
- Startup cleanup of orphaned processes from previous runs
100+
101+
- **WebSocket connection handling**
102+
103+
- Moved filesystem sync operations after connection close to prevent blocking
104+
- Improved connection resource management during slow storage operations
105+
106+
### Changed
107+
108+
- **Configuration system**: Centralized in `config.py` with environment variable and YAML file support
109+
- **Process title tracking**: Uses `setproctitle` for easier process identification and management
110+
111+
### Documentation
112+
113+
- **[README.md](README.md)**: Complete guide to both pipe and WebSocket modes with configuration examples
114+
- **[LOG_FILTERING.md](docs/LOG_FILTERING.md)**: Client-side log filtering with custom handler examples
115+
- **[CEPHFS_ARCHITECTURE.md](docs/CEPHFS_ARCHITECTURE.md)**: CephFS architecture and diagnostic guide
116+
117+
### Migration Guide
118+
119+
#### For Existing Deployments
120+
121+
**No action required** - The default behavior (`USE_SHARES=false`) maintains full backward compatibility with the existing pipe-based client. All current deployments will continue to work without any changes.
122+
123+
#### To Adopt WebSocket Mode
124+
125+
WebSocket mode requires:
126+
127+
- Shared filesystem accessible by both clients and servers
128+
- WebSocket server(s) running on worker nodes
129+
- Network connectivity between clients and servers
130+
131+
**1. Enable WebSocket client:**
132+
133+
```bash
134+
# Environment variable
135+
export MARS_USE_SHARES=true
136+
137+
# Or in /etc/cads-mars-server.yaml
138+
use_shares: true
139+
```
140+
141+
**2. Configure WebSocket server list:**
142+
143+
```bash
144+
# Environment variable (comma-separated)
145+
export MARS_WS_SERVERS="ws://worker1:9001,ws://worker2:9001"
146+
147+
# Or in configuration file
148+
mars_ws_servers:
149+
- ws://worker1:9001
150+
- ws://worker2:9001
151+
```
152+
153+
**3. Start WebSocket server on worker nodes:**
154+
155+
```bash
156+
ws-mars-server --host 0.0.0.0 --port 9001
157+
```
158+
159+
See [README.md](README.md) for complete deployment examples.
160+
161+
### Breaking Changes
162+
163+
- **Dependency version requirement**: Applications using `USE_SHARES=true` must use `cads-mars-server>=0.3.0`
164+
- **Shared filesystem required**: WebSocket mode assumes client and server have access to the same filesystem paths
165+
- **Custom log handlers**: Must be `async` functions (default filtering works without changes)
166+
167+
______________________________________________________________________
168+
169+
## [0.2.5.1] - Previous Release
170+
171+
(Earlier changes not documented)

0 commit comments

Comments
 (0)