Compare commits

...

2 Commits

Author SHA1 Message Date
GSRN
e787aa64a3 fix cache server
Some checks failed
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 24s
Docker Build and Push / build-and-push (push) Failing after 37s
Integration Tests / integration-tests (push) Failing after 10m35s
LabFusion CI/CD Pipeline / frontend (push) Failing after 10m42s
LabFusion CI/CD Pipeline / api-docs (push) Failing after 10m42s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 10m55s
LabFusion CI/CD Pipeline / integration-tests (push) Has been cancelled
Integration Tests / performance-tests (push) Has been cancelled
2025-09-15 17:05:08 +02:00
GSRN
65c93ae685 fix: Resolve host.docker.internal hostname resolution issue
- Change cache host from 'host.docker.internal' to empty string
- Allow act_runner to auto-detect the correct host IP address
- Update all runner configs: docker, heavy, light, security
- Improve troubleshooting scripts with host IP detection:
  - Linux/macOS: Use ip route, hostname -I, or ifconfig
  - Windows: Use Get-NetIPAddress PowerShell cmdlets
- Update documentation to reflect auto-detection approach

This resolves the 'getaddrinfo ENOTFOUND host.docker.internal' error
by using a more compatible approach that works across different
Docker setups and operating systems.
2025-09-15 17:00:04 +02:00
7 changed files with 88 additions and 24 deletions

View File

@@ -32,7 +32,7 @@ This ensures that cache failures don't cause the entire pipeline to fail.
### 2. Runner Configuration Fixes ### 2. Runner Configuration Fixes
Updated all existing runner configuration files with: Updated all existing runner configuration files with:
- **Fixed Host**: `host.docker.internal` (allows containers to access host) - **Auto-detect Host**: Empty host field (allows act_runner to auto-detect the correct IP)
- **Fixed Port**: `44029` (instead of random port 0) - **Fixed Port**: `44029` (instead of random port 0)
- **Host Network**: Uses host networking for better connectivity - **Host Network**: Uses host networking for better connectivity
@@ -91,7 +91,7 @@ Update your runner configuration with these key changes:
```yaml ```yaml
cache: cache:
enabled: true enabled: true
host: "host.docker.internal" # Fixed host host: "" # Auto-detect host IP
port: 44029 # Fixed port port: 44029 # Fixed port
container: container:

View File

@@ -54,11 +54,11 @@ cache:
# If it's empty, the cache data will be stored in $HOME/.cache/actcache. # If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "" dir: ""
# The host of the cache server. # The host of the cache server.
# Use host.docker.internal to allow containers to access the host # Leave empty to auto-detect the host IP address
# This fixes the common networking issue where containers can't reach the cache server # This is more compatible across different Docker setups
host: "host.docker.internal" host: ""
# Use a fixed port instead of random to avoid connection issues # Use a fixed port instead of random to avoid connection issues
port: 44029 port: 40047
# The external cache server URL. Valid only when enable is true. # The external cache server URL. Valid only when enable is true.
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
# The URL should generally end with "/". # The URL should generally end with "/".

View File

@@ -54,11 +54,11 @@ cache:
# If it's empty, the cache data will be stored in $HOME/.cache/actcache. # If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "" dir: ""
# The host of the cache server. # The host of the cache server.
# Use host.docker.internal to allow containers to access the host # Leave empty to auto-detect the host IP address
# This fixes the common networking issue where containers can't reach the cache server # This is more compatible across different Docker setups
host: "host.docker.internal" host: ""
# Use a fixed port instead of random to avoid connection issues # Use a fixed port instead of random to avoid connection issues
port: 44029 port: 40047
# The external cache server URL. Valid only when enable is true. # The external cache server URL. Valid only when enable is true.
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
# The URL should generally end with "/". # The URL should generally end with "/".

View File

@@ -54,11 +54,11 @@ cache:
# If it's empty, the cache data will be stored in $HOME/.cache/actcache. # If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "" dir: ""
# The host of the cache server. # The host of the cache server.
# Use host.docker.internal to allow containers to access the host # Leave empty to auto-detect the host IP address
# This fixes the common networking issue where containers can't reach the cache server # This is more compatible across different Docker setups
host: "host.docker.internal" host: ""
# Use a fixed port instead of random to avoid connection issues # Use a fixed port instead of random to avoid connection issues
port: 44029 port: 40047
# The external cache server URL. Valid only when enable is true. # The external cache server URL. Valid only when enable is true.
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
# The URL should generally end with "/". # The URL should generally end with "/".

View File

@@ -54,11 +54,11 @@ cache:
# If it's empty, the cache data will be stored in $HOME/.cache/actcache. # If it's empty, the cache data will be stored in $HOME/.cache/actcache.
dir: "" dir: ""
# The host of the cache server. # The host of the cache server.
# Use host.docker.internal to allow containers to access the host # Leave empty to auto-detect the host IP address
# This fixes the common networking issue where containers can't reach the cache server # This is more compatible across different Docker setups
host: "host.docker.internal" host: ""
# Use a fixed port instead of random to avoid connection issues # Use a fixed port instead of random to avoid connection issues
port: 44029 port: 40047
# The external cache server URL. Valid only when enable is true. # The external cache server URL. Valid only when enable is true.
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
# The URL should generally end with "/". # The URL should generally end with "/".

View File

@@ -68,6 +68,35 @@ function Test-NetworkConnectivity {
} }
} }
# 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 to fix common cache issues
function Fix-CacheIssues { function Fix-CacheIssues {
Write-Host "🔧 Applying cache fixes..." -ForegroundColor Cyan Write-Host "🔧 Applying cache fixes..." -ForegroundColor Cyan
@@ -76,12 +105,15 @@ function Fix-CacheIssues {
$cacheDir = "$env:USERPROFILE\.cache\actcache" $cacheDir = "$env:USERPROFILE\.cache\actcache"
New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null New-Item -ItemType Directory -Path $cacheDir -Force | Out-Null
# Detect host IP
$hostIP = Get-HostIP
# Set proper environment variables # Set proper environment variables
$env:ACTIONS_CACHE_URL = "http://host.docker.internal:44029/" $env:ACTIONS_CACHE_URL = "http://${hostIP}:44029/"
$env:ACTIONS_RUNTIME_URL = "http://host.docker.internal:44029/" $env:ACTIONS_RUNTIME_URL = "http://${hostIP}:44029/"
Write-Host "✅ Cache directory created and configured" -ForegroundColor Green Write-Host "✅ Cache directory created and configured" -ForegroundColor Green
Write-Host "✅ Environment variables set" -ForegroundColor Green Write-Host "✅ Environment variables set with host IP: $hostIP" -ForegroundColor Green
} }
# Function to restart cache service # Function to restart cache service

View File

@@ -62,6 +62,35 @@ test_network() {
fi fi
} }
# Function to detect the correct host IP
detect_host_ip() {
echo "🔍 Detecting host IP address..."
# Try different methods to get the host IP
if command -v ip > /dev/null 2>&1; then
# Linux with ip command
HOST_IP=$(ip route get 1.1.1.1 | awk '{print $7; exit}' 2>/dev/null)
elif command -v hostname > /dev/null 2>&1; then
# Try hostname -I (Linux)
HOST_IP=$(hostname -I | awk '{print $1}' 2>/dev/null)
elif command -v ifconfig > /dev/null 2>&1; then
# Try ifconfig (macOS/BSD)
HOST_IP=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -1)
else
# Fallback to localhost
HOST_IP="127.0.0.1"
fi
if [ -z "$HOST_IP" ] || [ "$HOST_IP" = "127.0.0.1" ]; then
echo "⚠️ Could not detect host IP, using localhost"
HOST_IP="127.0.0.1"
else
echo "✅ Detected host IP: $HOST_IP"
fi
echo "$HOST_IP"
}
# Function to fix common cache issues # Function to fix common cache issues
fix_cache_issues() { fix_cache_issues() {
echo "🔧 Applying cache fixes..." echo "🔧 Applying cache fixes..."
@@ -71,12 +100,15 @@ fix_cache_issues() {
mkdir -p "$CACHE_DIR" mkdir -p "$CACHE_DIR"
chmod 755 "$CACHE_DIR" chmod 755 "$CACHE_DIR"
# Detect host IP
HOST_IP=$(detect_host_ip)
# Set proper environment variables # Set proper environment variables
export ACTIONS_CACHE_URL="http://host.docker.internal:44029/" export ACTIONS_CACHE_URL="http://${HOST_IP}:44029/"
export ACTIONS_RUNTIME_URL="http://host.docker.internal:44029/" export ACTIONS_RUNTIME_URL="http://${HOST_IP}:44029/"
echo "✅ Cache directory created and configured" echo "✅ Cache directory created and configured"
echo "✅ Environment variables set" echo "✅ Environment variables set with host IP: $HOST_IP"
} }
# Function to restart cache service # Function to restart cache service