Files
labFusion/runners/fix-cache-issues.sh
GSRN 79250ea3ab
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 31s
API Docs (Node.js Express) / test (20) (push) Successful in 3m56s
API Docs (Node.js Express) / test (16) (push) Successful in 4m4s
API Docs (Node.js Express) / test (18) (push) Successful in 4m10s
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 1m22s
LabFusion CI/CD Pipeline / api-docs (push) Successful in 1m2s
API Gateway (Java Spring Boot) / test (17) (push) Failing after 2m39s
API Gateway (Java Spring Boot) / test (21) (push) Failing after 2m45s
API Gateway (Java Spring Boot) / build (push) Has been skipped
API Gateway (Java Spring Boot) / security (push) Has been skipped
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 3m21s
Frontend (React) / test (16) (push) Failing after 1m46s
LabFusion CI/CD Pipeline / frontend (push) Failing after 1m59s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
Frontend (React) / test (18) (push) Failing after 1m50s
Integration Tests / integration-tests (push) Failing after 49s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 1m7s
Frontend (React) / test (20) (push) Failing after 2m30s
Frontend (React) / build (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 1m43s
Frontend (React) / lighthouse (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 1m2s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 1m43s
Service Adapters (Python FastAPI) / build (push) Has been skipped
API Docs (Node.js Express) / build (push) Successful in 59s
refactor: Apply cache fixes directly to existing runner configs
- Update all runner configuration files with cache networking fixes:
  - config_docker.yaml
  - config_heavy.yaml
  - config_light.yaml
  - config_security.yaml
- Remove separate config_cache_fixed.yaml file
- Update troubleshooting scripts to use updated configs
- Update documentation to reference existing config files

All runner configs now have:
- Fixed cache host: host.docker.internal
- Fixed cache port: 44029
- Host networking for better container connectivity

This provides a cleaner approach by updating existing configs
instead of maintaining a separate fixed configuration file.
2025-09-15 16:44:16 +02:00

171 lines
4.5 KiB
Bash

#!/bin/bash
# Cache Troubleshooting and Fix Script for LabFusion CI/CD
# This script helps diagnose and fix common cache timeout issues
set -e
echo "🔧 LabFusion Cache Troubleshooting Script"
echo "=========================================="
# Function to check if running in Docker
check_docker() {
if [ -f /.dockerenv ]; then
echo "🐳 Running inside Docker container"
return 0
else
echo "🖥️ Running on host system"
return 1
fi
}
# Function to check cache service status
check_cache_service() {
echo "📊 Checking cache service status..."
# Check if cache service is running
if pgrep -f "act_runner" > /dev/null; then
echo "✅ act_runner process found"
else
echo "❌ act_runner process not found"
return 1
fi
# Check cache directory
CACHE_DIR="${HOME}/.cache/actcache"
if [ -d "$CACHE_DIR" ]; then
echo "✅ Cache directory exists: $CACHE_DIR"
echo " Size: $(du -sh "$CACHE_DIR" 2>/dev/null || echo "Unknown")"
else
echo "⚠️ Cache directory not found: $CACHE_DIR"
echo " Creating cache directory..."
mkdir -p "$CACHE_DIR"
fi
}
# Function to test network connectivity
test_network() {
echo "🌐 Testing network connectivity..."
# Test basic connectivity
if ping -c 1 8.8.8.8 > /dev/null 2>&1; then
echo "✅ Internet connectivity OK"
else
echo "❌ Internet connectivity failed"
fi
# Test Docker daemon
if docker info > /dev/null 2>&1; then
echo "✅ Docker daemon accessible"
else
echo "❌ Docker daemon not accessible"
fi
}
# Function to fix common cache issues
fix_cache_issues() {
echo "🔧 Applying cache fixes..."
# Create cache directory with proper permissions
CACHE_DIR="${HOME}/.cache/actcache"
mkdir -p "$CACHE_DIR"
chmod 755 "$CACHE_DIR"
# Set proper environment variables
export ACTIONS_CACHE_URL="http://host.docker.internal:44029/"
export ACTIONS_RUNTIME_URL="http://host.docker.internal:44029/"
echo "✅ Cache directory created and configured"
echo "✅ Environment variables set"
}
# Function to restart cache service
restart_cache_service() {
echo "🔄 Restarting cache service..."
# Stop existing runners
pkill -f "act_runner" || true
sleep 2
# Start with updated configuration
if [ -f "config_docker.yaml" ]; then
echo "✅ Using updated Docker configuration"
nohup ./act_runner daemon --config config_docker.yaml > runner.log 2>&1 &
elif [ -f "config_heavy.yaml" ]; then
echo "✅ Using updated heavy configuration"
nohup ./act_runner daemon --config config_heavy.yaml > runner.log 2>&1 &
else
echo "⚠️ Updated configuration not found, using default"
nohup ./act_runner daemon > runner.log 2>&1 &
fi
sleep 5
if pgrep -f "act_runner" > /dev/null; then
echo "✅ Cache service restarted successfully"
else
echo "❌ Failed to restart cache service"
return 1
fi
}
# Function to test cache functionality
test_cache() {
echo "🧪 Testing cache functionality..."
# Create a test cache entry
TEST_KEY="test-cache-$(date +%s)"
TEST_VALUE="test-value-$(date +%s)"
echo " Creating test cache entry: $TEST_KEY"
echo "$TEST_VALUE" > "/tmp/cache-test"
# Try to restore (this will fail but we can check the error)
echo " Testing cache restore..."
if curl -s "http://host.docker.internal:44029/cache/$TEST_KEY" > /dev/null 2>&1; then
echo "✅ Cache service responding"
else
echo "❌ Cache service not responding"
echo " This is expected if no cache entry exists"
fi
# Clean up
rm -f "/tmp/cache-test"
}
# Main execution
main() {
echo "Starting cache troubleshooting..."
echo ""
check_docker
echo ""
check_cache_service
echo ""
test_network
echo ""
fix_cache_issues
echo ""
restart_cache_service
echo ""
test_cache
echo ""
echo "🎉 Cache troubleshooting complete!"
echo ""
echo "Next steps:"
echo "1. Check runner logs: tail -f runner.log"
echo "2. Test a workflow to see if cache issues are resolved"
echo "3. If issues persist, check Docker networking configuration"
echo ""
echo "For more help, see: https://gitea.com/gitea/act_runner/src/branch/main/docs/configuration.md"
}
# Run main function
main "$@"