This guide covers troubleshooting for the native vSock relay implementation that replaces the socat workaround.
The implementation uses a two-volume approach for PostgreSQL:
honcho-db-data(disk image): Database files at/var/lib/postgresql/datahoncho-db-sockets(directory): Socket files at/var/run/postgresql/sockets
The socket is visible to the host via Virtio-FS mount at:
~/.containers/Volumes/apple-honcho/honcho-db-sockets/.s.PGSQL.5432
Symptom: PostgreSQL is running but the socket file doesn't appear in the Virtio-FS volume.
Diagnosis:
# Check if socket exists in container
container exec apple-honcho-honcho-db ls -la /var/run/postgresql/sockets/
# Check Virtio-FS volume on host
ls -la ~/.containers/Volumes/apple-honcho/honcho-db-sockets/Possible causes:
- PostgreSQL not configured to use the socket directory
- Volume not mounted correctly
- PostgreSQL still initializing
Solution: Ensure YAML includes:
command:
- postgres
- -c
- unix_socket_directories=/var/run/postgresql/socketsSymptom: VsockRelay fails with timeout error.
Diagnosis:
# Check relay logs
container-compose logs honcho-dbPossible causes:
- Socket path mismatch between container and host
- 60-second timeout exceeded during PostgreSQL startup
Solution:
- Verify
socket_pathin YAML matches Virtio-FS mount path - Increase timeout if needed (currently hardcoded at 60s in VsockRelay.swift:120)
Symptom: Connections to vsock fail with connection refused.
Note: Current implementation uses "Ambient" path (Unix socket over Virtio-FS) which doesn't require correct CID for initial connection. The vsock CID only matters for the data transfer phase.
For future Pure vSock implementation: CID discovery is not yet implemented. The default CID is 2 (host).
Symptom: Applications can't connect to database.
Diagnosis:
# Test connection from host
psql -h localhost -p 5432 -U postgres -d honcho
# Check if relay is listening
lsof -i :5432Possible causes:
- Relay not started
- Socket file not accessible
- Network configuration issue
Sources/Container-Compose/Networking/VsockRelay.swift- Relay implementationSources/Container-Compose/Networking/RelayManager.swift- Relay orchestrationSources/Container-Compose/Commands/ComposeUp.swift- Relay startup
None required - all configuration via YAML x-apple-relays section.
If native relay fails, revert to socat:
# Stop containers
container-compose down
# Use old YAML (without socket_path)
container-compose up -f honcho-stack-legacy.yml -d- CID Discovery: Not implemented - uses default CID 2
- Pure vSock Path: Not implemented - uses "Ambient" path via Virtio-FS
- Performance: Ambient path has higher metadata overhead than pure vsock
- Ensure Plan 85 build errors are fixed
- Backup existing database if needed
- Deploy with new YAML:
container-compose up -d - Verify honcho-db container starts
# Check socket appears in Virtio-FS volume
ls -la ~/.containers/Volumes/apple-honcho/honcho-db-sockets/
# Should show: .s.PGSQL.5432# Verify PostgreSQL created socket in correct location
container exec apple-honcho-honcho-db ls -la /var/run/postgresql/sockets/
# Verify PostgreSQL is listening
container exec apple-honcho-honcho-db pg_isready# From host, test connection via relay
psql -h localhost -p 5432 -U postgres -d honcho -c "SELECT 1;"
# Should return: ?column? = 1# Time the deployment
time container-compose up -d
# Target: < 5 seconds (vs 30s timeout with socat)- Phase 5 validation passes
- Plan 85 security gating integrated (optional)
- Remove socat from base image Dockerfile
- Update documentation
- Archive socat workaround notes
VsockRelay.swift lines 117-131:
// Wait for PostgreSQL socket in Virtio-FS volume
let startTime = Date()
while Date().timeIntervalSince(startTime) < 60 { // 60s timeout
// Poll every 500ms for socket file
try await Task.sleep(nanoseconds: 500_000_000)
}| Phase | Estimated Time |
|---|---|
| Container start | 2-5 seconds |
| PostgreSQL init | 3-10 seconds |
| Socket creation | < 1 second |
| Relay start | < 1 second |
| Total | ~10-15 seconds |
- Target: < 5 seconds (Plan 84 objective)
- With socat: ~30 seconds (previous timeout)
- Expected with native relay: ~10-15 seconds
# Time the full deployment
time container-compose up -d
# Check relay logs for timing
container-compose logs honcho-db | grep -E "(socket|relay|started)"- Reduce timeout: Currently 60s, could be 30s if PostgreSQL starts faster
- Faster polling: 500ms could be reduced to 100ms for faster failure detection
- Health check integration: Use PostgreSQL healthcheck instead of socket polling
The 60s timeout was chosen conservatively. If PostgreSQL takes longer to initialize (cold start, large database), the relay will wait up to 60 seconds before failing.
Production volumes at ~/.containers/Volumes/ can be leveraged for runtime validation tests instead of temporary CCT_* test volumes. This provides more realistic testing against actual container runtime behavior.
~/.containers/Volumes/apple-honcho/honcho-db-data/- Existing production database volume~/.containers/Volumes/apple/- General production volumes~/.containers/Volumes/_devcontainer/- Development container volumes
Test File: Tests/Container-Compose-DynamicTests/ProductionVolumeDynamicTests.swift
Test Coverage:
testSocketCreationInProductionVolume()- VsockRelay socket creation in real volumestestVirtioFsSocketForwarding()- Bidirectional communication validationtestVolumeSocketPathDetection()- isVolumeSocket detection with production pathstestSocketPersistenceAcrossRelayRestart()- Socket survival across restartstestProductionVolumeStructure()- Volume structure verificationtestSocketPathPermissions()- Permission validation in production volumes
# Run production volume tests
swift test --filter ProductionVolumeDynamicTests- Tests run against real production volumes, not temporary CCT_* test volumes
- Validates actual Virtio-FS behavior with container runtime
- No need to wait for YAML deployment to test socket forwarding
- Uses existing test infrastructure (ComposeUpDynamicTests pattern)
Automated deployment validation script that tests prerequisites, YAML configuration, startup time, and socket creation.
Tests/test_deployment_validation.sh
- Prerequisites - container-compose binary, production volumes
- YAML Configuration - x-apple-relays, socket_path validation
- Startup Time - Target < 5 seconds measurement
- Socket Creation - Virtio-FS volume socket creation
- Virtio-FS Detection - Path detection validation
- Relay Configuration - VsockRelay and RelayManager verification
- Production Volumes - Volume existence checks
# Run deployment validation
cd Tests && ./test_deployment_validation.sh
# Output includes:
# - Colored logging with timestamps
# - Detailed pass/fail results
# - Log file: logs/deployment_validation_YYYYMMDD_HHMMSS.log- Startup time < 5 seconds (vs 30s with socat)
- Socket visible in Virtio-FS mount
- All prerequisite checks pass
- YAML configuration validates
Integration tests for actual database connectivity through vsock relay, including query execution, connection pooling, and transaction handling.
Tests/Container-Compose-DynamicTests/DatabaseConnectivityIntegrationTests.swift
testPostgresConnectionViaVsockRelay()- Direct connection testtestQueryExecution()- SELECT, INSERT, UPDATE, DROP operationstestConnectionPooling()- Multiple concurrent connections (5)testTransactionHandling()- BEGIN, COMMIT, ROLLBACKtestLargeResultSet()- Performance with 100 rowstestConnectionResilience()- Connection through relay restarts
Tests use MockDatabaseConnection actor that simulates PostgreSQL client behavior without requiring actual database.
# Run database connectivity tests
swift test --filter DatabaseConnectivityIntegrationTests- Async/await patterns throughout
- Connection timeout handling (10s)
- Concurrent query testing with TaskGroup
- Transaction rollback verification
- Performance measurement for large result sets
# Full test suite with cleanup
./run-tests.sh --auto-clean
# Static tests only (no container runtime)
./run-tests.sh --static
# Dynamic tests only (requires container runtime)
./run-tests.sh --dynamic
# Specific test class
swift test --filter ProductionVolumeDynamicTests
swift test --filter DatabaseConnectivityIntegrationTests- Logs:
logs/test_run_YYYYMMDD_HHMMSS.log - Reports:
Tests/TestReports/ - Deployment validation logs:
logs/deployment_validation_*.log