Skip to content

Conversation

@X9X0
Copy link
Owner

@X9X0 X9X0 commented Nov 20, 2025

🐛 Critical Fixes
Server Container Crash on Fresh Pi Image

Root Cause: Missing requests dependency caused ModuleNotFoundError on startup
Fix: Added requests==2.32.4 to server/requirements.txt with security patches
Impact: Server containers now start successfully without crash-looping
Unreliable LabLink Service Startup

Problem: lablink.service used Type=oneshot with no restart policy and insufficient wait times
Fix: Enhanced systemd service configuration in build-pi-image.sh:
Changed to Type=forking for proper container process management
Added Restart=on-failure with 10s exponential backoff
Extended timeouts: 120s start, 30s stop
Improved health checks: waits up to 30s for containers to be healthy
Added Docker daemon readiness check: waits up to 60s before starting
Impact: LabLink automatically recovers from failures and handles boot timing issues
Diagnostic Script Not Accessible in Container

Problem: diagnose-pi.sh existed on host but not inside Docker container
Fix: Updated Dockerfile.server to copy script and install required tools (sudo, iproute2, iputils-ping, procps)
Impact: Pi diagnostics endpoint now works correctly
✨ New Features
Comprehensive Pi Diagnostics System

Integrated diagnostic tooling accessible directly from the LabLink client GUI:

  1. Diagnostic Script (diagnose-pi.sh)

System information (hostname, uptime, Pi model)
Network status (IP addresses, connectivity, DNS)
Docker status and daemon health
LabLink installation verification
Service and container status
Port listener detection
Recent logs analysis
Automated recommendations for common issues
2. Server API (POST /api/diagnostics/pi-diagnostics)

Executes diagnostic script on Pi server
60-second timeout with full output capture
Returns structured results with exit codes
3. Client API (client.run_pi_diagnostics())

90-second timeout for network latency
Clean error handling
4. GUI Integration (Diagnostics Panel)

"Run Pi Diagnostics" button in Diagnostics tab
Beautiful results dialog featuring:
Scrollable monospace output
Copy to clipboard button
Save to timestamped file (e.g., pi-diagnostics-20251120-142530.txt)
Color-coded success/failure status
Clear error messages with troubleshooting hints
5. Version Verification Script (verify-pi-code.sh)

Verify what code version is running on Pi
Check if endpoints exist in deployed code
Validate dependencies in containers
Useful for troubleshooting version mismatches
🎯 Benefits
✅ No more "Connection Refused" errors on fresh Pi images
✅ Automatic service recovery if containers crash
✅ One-click troubleshooting without SSH access
✅ Streamlined debugging with comprehensive system reports
✅ Easy issue sharing via copy/save functionality
✅ Better resilience to boot timing issues on slower Pi models
✅ Version verification to diagnose deployment issues
📝 Usage
For Existing Pi (to apply fixes):

cd /opt/lablink
sudo git pull origin main
sudo docker compose down
sudo docker compose build --no-cache
sudo docker compose up -d
For New Pi Images:

Rebuild Pi image using the updated build-pi-image.sh
All fixes automatically included
For GUI Diagnostics:

Connect to Pi server in LabLink client
Navigate to Diagnostics tab
Click "Run Pi Diagnostics"
View/copy/save comprehensive report
🔧 Files Changed
server/requirements.txt - Added requests==2.32.4 with security fixes
build-pi-image.sh - Enhanced systemd service and first-boot script
diagnose-pi.sh - New comprehensive diagnostic script
verify-pi-code.sh - New version verification script
server/api/diagnostics.py - New Pi diagnostics endpoint
client/api/client.py - New run_pi_diagnostics() method
client/ui/diagnostics_panel.py - GUI integration with results dialog
docker/Dockerfile.server - Copy diagnostic script and install required tools
🔒 Security
Upgraded requests from 2.31.0 to 2.32.4
Fixes GHSA-9wx4-h78v-vm56: Certificate verification bypass
Fixes GHSA-9hjg-9r4m-mvj7: .netrc credential leak

Diagnostic script to verify what code version is running on the Pi server:
- Check git commit and branch
- Verify Pi diagnostics endpoint exists in code
- Check if diagnose-pi.sh script is present
- Show requests dependency version
- Inspect Docker container packages
- Test API endpoint availability
- Show last update timestamp

Useful for troubleshooting version mismatch issues between client and server.
The Pi diagnostics endpoint was returning 404 because the diagnose-pi.sh
script exists on the host filesystem but not inside the Docker container.

Changes:
- Install sudo, iproute2, iputils-ping, procps in container (needed by script)
- Copy diagnose-pi.sh into container at /app/diagnose-pi.sh
- Make script executable

This allows the /api/diagnostics/pi-diagnostics endpoint to find and
execute the diagnostic script from inside the container.

Fixes: "Diagnostic script not found" error when running Pi diagnostics
@X9X0 X9X0 merged commit 9791cbf into main Nov 20, 2025
25 checks passed
@X9X0 X9X0 deleted the claude/debug-client-server-pi-013gro9B5KVA6EY6mD2JLUoL branch November 20, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants