- Replace 'mvn' commands with './mvnw' in CI workflow - Add chmod +x ./mvnw step to make Maven wrapper executable - Add cache: maven to Java setup step for better caching - Update troubleshooting scripts to use correct port 40047 - Update documentation to reflect port change This fixes the 'mvn: command not found' error by ensuring all Maven commands use the Maven wrapper (mvnw) which is included in the project and doesn't require Maven to be pre-installed on the runner.
212 lines
7.9 KiB
PowerShell
212 lines
7.9 KiB
PowerShell
# Cache Troubleshooting and Fix Script for LabFusion CI/CD
|
|
# This script helps diagnose and fix common cache timeout issues
|
|
|
|
Write-Host "🔧 LabFusion Cache Troubleshooting Script" -ForegroundColor Cyan
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
|
|
# Function to check if running in Docker
|
|
function Test-Docker {
|
|
if (Test-Path "/.dockerenv") {
|
|
Write-Host "🐳 Running inside Docker container" -ForegroundColor Green
|
|
return $true
|
|
} else {
|
|
Write-Host "🖥️ Running on host system" -ForegroundColor Yellow
|
|
return $false
|
|
}
|
|
}
|
|
|
|
# Function to check cache service status
|
|
function Test-CacheService {
|
|
Write-Host "📊 Checking cache service status..." -ForegroundColor Cyan
|
|
|
|
# Check if act_runner process is running
|
|
$processes = Get-Process -Name "act_runner" -ErrorAction SilentlyContinue
|
|
if ($processes) {
|
|
Write-Host "✅ act_runner process found" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "❌ act_runner process not found" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
|
|
# Check cache directory
|
|
$cacheDir = "$env:USERPROFILE\.cache\actcache"
|
|
if (Test-Path $cacheDir) {
|
|
Write-Host "✅ Cache directory exists: $cacheDir" -ForegroundColor Green
|
|
$size = (Get-ChildItem $cacheDir -Recurse | Measure-Object -Property Length -Sum).Sum
|
|
Write-Host " Size: $([math]::Round($size / 1MB, 2)) MB" -ForegroundColor Gray
|
|
} else {
|
|
Write-Host "⚠️ Cache directory not found: $cacheDir" -ForegroundColor Yellow
|
|
Write-Host " Creating cache directory..." -ForegroundColor Yellow
|
|
New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null
|
|
}
|
|
|
|
return $true
|
|
}
|
|
|
|
# Function to test network connectivity
|
|
function Test-NetworkConnectivity {
|
|
Write-Host "🌐 Testing network connectivity..." -ForegroundColor Cyan
|
|
|
|
# Test basic connectivity
|
|
try {
|
|
$ping = Test-Connection -ComputerName "8.8.8.8" -Count 1 -Quiet
|
|
if ($ping) {
|
|
Write-Host "✅ Internet connectivity OK" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "❌ Internet connectivity failed" -ForegroundColor Red
|
|
}
|
|
} catch {
|
|
Write-Host "❌ Internet connectivity test failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
# Test Docker daemon
|
|
try {
|
|
docker info | Out-Null
|
|
Write-Host "✅ Docker daemon accessible" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "❌ Docker daemon not accessible" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
# Function to detect the correct host IP
|
|
function Get-HostIP {
|
|
Write-Host "🔍 Detecting host IP address..." -ForegroundColor Cyan
|
|
|
|
try {
|
|
# Try to get the IP address of the default gateway interface
|
|
$networkAdapters = Get-NetAdapter | Where-Object { $_.Status -eq "Up" -and $_.Name -notlike "*Loopback*" }
|
|
if ($networkAdapters) {
|
|
$ipConfig = Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
|
|
$_.InterfaceAlias -in $networkAdapters.Name -and $_.IPAddress -ne "127.0.0.1"
|
|
} | Select-Object -First 1
|
|
|
|
if ($ipConfig) {
|
|
$hostIP = $ipConfig.IPAddress
|
|
Write-Host "✅ Detected host IP: $hostIP" -ForegroundColor Green
|
|
return $hostIP
|
|
}
|
|
}
|
|
|
|
# Fallback to localhost
|
|
Write-Host "⚠️ Could not detect host IP, using localhost" -ForegroundColor Yellow
|
|
return "127.0.0.1"
|
|
} catch {
|
|
Write-Host "⚠️ Error detecting host IP: $($_.Exception.Message)" -ForegroundColor Yellow
|
|
Write-Host " Using localhost as fallback" -ForegroundColor Gray
|
|
return "127.0.0.1"
|
|
}
|
|
}
|
|
|
|
# Function to fix common cache issues
|
|
function Fix-CacheIssues {
|
|
Write-Host "🔧 Applying cache fixes..." -ForegroundColor Cyan
|
|
|
|
# Create cache directory with proper permissions
|
|
$cacheDir = "$env:USERPROFILE\.cache\actcache"
|
|
New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null
|
|
|
|
# Detect host IP
|
|
$hostIP = Get-HostIP
|
|
|
|
# Set proper environment variables
|
|
$env:ACTIONS_CACHE_URL = "http://${hostIP}:40047/"
|
|
$env:ACTIONS_RUNTIME_URL = "http://${hostIP}:40047/"
|
|
|
|
Write-Host "✅ Cache directory created and configured" -ForegroundColor Green
|
|
Write-Host "✅ Environment variables set with host IP: $hostIP" -ForegroundColor Green
|
|
}
|
|
|
|
# Function to restart cache service
|
|
function Restart-CacheService {
|
|
Write-Host "🔄 Restarting cache service..." -ForegroundColor Cyan
|
|
|
|
# Stop existing runners
|
|
Get-Process -Name "act_runner" -ErrorAction SilentlyContinue | Stop-Process -Force
|
|
Start-Sleep -Seconds 2
|
|
|
|
# Start with updated configuration
|
|
if (Test-Path "config_docker.yaml") {
|
|
Write-Host "✅ Using updated Docker configuration" -ForegroundColor Green
|
|
Start-Process -FilePath ".\act_runner.exe" -ArgumentList "daemon", "--config", "config_docker.yaml" -WindowStyle Hidden
|
|
} elseif (Test-Path "config_heavy.yaml") {
|
|
Write-Host "✅ Using updated heavy configuration" -ForegroundColor Green
|
|
Start-Process -FilePath ".\act_runner.exe" -ArgumentList "daemon", "--config", "config_heavy.yaml" -WindowStyle Hidden
|
|
} else {
|
|
Write-Host "⚠️ Updated configuration not found, using default" -ForegroundColor Yellow
|
|
Start-Process -FilePath ".\act_runner.exe" -ArgumentList "daemon" -WindowStyle Hidden
|
|
}
|
|
|
|
Start-Sleep -Seconds 5
|
|
|
|
$processes = Get-Process -Name "act_runner" -ErrorAction SilentlyContinue
|
|
if ($processes) {
|
|
Write-Host "✅ Cache service restarted successfully" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "❌ Failed to restart cache service" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
|
|
return $true
|
|
}
|
|
|
|
# Function to test cache functionality
|
|
function Test-CacheFunctionality {
|
|
Write-Host "🧪 Testing cache functionality..." -ForegroundColor Cyan
|
|
|
|
# Create a test cache entry
|
|
$testKey = "test-cache-$(Get-Date -Format 'yyyyMMddHHmmss')"
|
|
$testValue = "test-value-$(Get-Date -Format 'yyyyMMddHHmmss')"
|
|
|
|
Write-Host " Creating test cache entry: $testKey" -ForegroundColor Gray
|
|
$testValue | Out-File -FilePath "C:\temp\cache-test.txt" -Force
|
|
|
|
# Try to test cache service (this will fail but we can check the error)
|
|
Write-Host " Testing cache service response..." -ForegroundColor Gray
|
|
try {
|
|
$response = Invoke-WebRequest -Uri "http://${hostIP}:40047/cache/$testKey" -TimeoutSec 5 -ErrorAction SilentlyContinue
|
|
Write-Host "✅ Cache service responding" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "❌ Cache service not responding: $($_.Exception.Message)" -ForegroundColor Yellow
|
|
Write-Host " This is expected if no cache entry exists" -ForegroundColor Gray
|
|
}
|
|
|
|
# Clean up
|
|
Remove-Item "C:\temp\cache-test.txt" -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# Main execution
|
|
function Main {
|
|
Write-Host "Starting cache troubleshooting..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
Test-Docker
|
|
Write-Host ""
|
|
|
|
Test-CacheService
|
|
Write-Host ""
|
|
|
|
Test-NetworkConnectivity
|
|
Write-Host ""
|
|
|
|
Fix-CacheIssues
|
|
Write-Host ""
|
|
|
|
Restart-CacheService
|
|
Write-Host ""
|
|
|
|
Test-CacheFunctionality
|
|
Write-Host ""
|
|
|
|
Write-Host "🎉 Cache troubleshooting complete!" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Next steps:" -ForegroundColor Yellow
|
|
Write-Host "1. Check runner logs in the current directory" -ForegroundColor White
|
|
Write-Host "2. Test a workflow to see if cache issues are resolved" -ForegroundColor White
|
|
Write-Host "3. If issues persist, check Docker networking configuration" -ForegroundColor White
|
|
Write-Host ""
|
|
Write-Host "For more help, see: https://gitea.com/gitea/act_runner/src/branch/main/docs/configuration.md" -ForegroundColor Cyan
|
|
}
|
|
|
|
# Run main function
|
|
Main
|