Implement ZMQ port management and kernel readiness checks
Container Configuration: - Added network_mode and port_bindings to ContainerConfig - Support for 'none', 'host', and 'bridge' network modes - Default remains 'none' for security Jupyter Kernel Manager: - Dynamic port allocation for 5 ZMQ channels using socket.socket() - _allocate_ports() finds available ports via OS binding - Host networking mode for Jupyter kernels (network_mode='host') - Connection file properly mounted into container - Port bindings tracked for documentation Kernel Readiness: - _wait_for_kernel_ready() polls shell port until kernel responds - Configurable timeout (30s) and poll interval (0.5s) - Replaced time.sleep(2) with proper connectivity check - Early return when kernel is ready This completes the core ZMQ communication infrastructure needed for real Jupyter kernel operation.
This commit is contained in:
parent
9cc43e4166
commit
14aba0a048
3 changed files with 128 additions and 34 deletions
|
|
@ -55,7 +55,20 @@
|
|||
- Error handling for injection failures
|
||||
- Passed through SessionManager and JupyterBackend
|
||||
|
||||
7. **Dependencies**
|
||||
7. **Network & Port Management**
|
||||
- Host networking mode for ZMQ communication (`network_mode="host"`)
|
||||
- Dynamic port allocation for 5 ZMQ channels (shell, iopub, stdin, control, hb)
|
||||
- Port availability checking before allocation
|
||||
- Port bindings tracked in ContainerConfig
|
||||
- Connection file mounted into container at `/tmp/kernel-{id}.json`
|
||||
|
||||
8. **Kernel Readiness**
|
||||
- `_wait_for_kernel_ready()`: Polls shell port until kernel responds
|
||||
- Configurable timeout (default 30s) and poll interval (0.5s)
|
||||
- Replaces simple sleep with proper port connectivity check
|
||||
- Returns early when kernel is ready
|
||||
|
||||
9. **Dependencies**
|
||||
- `jupyter-client>=8.8.0` added to server dependencies
|
||||
- `ipykernel` removed from server (will be in container image)
|
||||
- `pyzmq>=27.1.0` for ZMQ support
|
||||
|
|
@ -68,17 +81,7 @@
|
|||
|
||||
### 🚧 In Progress / TODO
|
||||
|
||||
1. **Container Configuration**
|
||||
- [ ] Port mappings for ZMQ sockets (shell, iopub, stdin, control, hb)
|
||||
- [ ] Mount connection file into container at `/tmp/kernel-{id}.json`
|
||||
- [ ] Proper network configuration for host-container ZMQ communication
|
||||
|
||||
2. **Kernel Readiness**
|
||||
- [ ] Replace `time.sleep(2)` with proper readiness check
|
||||
- [ ] Poll kernel status messages
|
||||
- [ ] Implement retry logic with timeout
|
||||
|
||||
3. **Restart Implementation**
|
||||
1. **Restart Implementation**
|
||||
- [ ] Use `KernelManager` instead of just `BlockingKernelClient`
|
||||
- [ ] Proper restart via `KernelManager.restart_kernel()`
|
||||
- [ ] Handle restart failures gracefully
|
||||
|
|
@ -145,16 +148,16 @@ Current test results: **20 failed, 2 passed**
|
|||
|
||||
1. **Immediate** (Core functionality):
|
||||
```
|
||||
1. Implement port mapping in ContainerConfig
|
||||
2. Mount connection file into container
|
||||
3. Test kernel startup with real container
|
||||
1. Update container image with ipykernel
|
||||
2. Test kernel startup with real container
|
||||
3. Mock tests for unit testing
|
||||
```
|
||||
|
||||
2. **Short-term** (Stability):
|
||||
```
|
||||
4. Implement proper readiness check
|
||||
5. Update container image with ipykernel
|
||||
6. Mock tests for unit testing
|
||||
4. Implement proper kernel restart
|
||||
5. Error handling improvements
|
||||
6. Port conflict handling
|
||||
```
|
||||
|
||||
3. **Medium-term** (Production-ready):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue