pr feedback

cloud-runner-develop
Frostebite 2026-01-17 16:32:54 +00:00
parent 5f552f2bc2
commit 828e65bdd7
4 changed files with 45 additions and 34 deletions

28
dist/index.js vendored
View File

@ -3760,19 +3760,15 @@ class Kubernetes {
// Extract image name without tag for matching
const imageName = image.split(':')[0];
const imageTag = image.split(':')[1] || 'latest';
// More targeted cleanup: remove stopped containers and non-Unity images
// IMPORTANT: Preserve Unity images to avoid re-pulling the 3.9GB image
// Strategy: Only remove containers, don't prune images (which might remove Unity image)
// More targeted cleanup: remove stopped containers only
// IMPORTANT: Do NOT remove images - preserve Unity image to avoid re-pulling the 3.9GB image
// Strategy: Only remove containers, never touch images (safest approach)
const cleanupCommands = [
// Remove all stopped containers (this frees runtime space but keeps images)
'docker exec k3d-unity-builder-agent-0 sh -c "crictl rm --all 2>/dev/null || true" || true',
'docker exec k3d-unity-builder-server-0 sh -c "crictl rm --all 2>/dev/null || true" || true',
// Remove specific non-Unity images by name (safer than filtering)
// Only remove known system images, preserve everything else including Unity
'docker exec k3d-unity-builder-agent-0 sh -c "crictl images --format \\"{{.Repository}}:{{.Tag}}\\" 2>/dev/null | grep -vE \\"unityci/editor|unity\\" | grep -E \\"rancher/|curlimages/|amazon/aws-cli|rclone/rclone|steamcmd/steamcmd|ubuntu:|alpine:\\" | xargs -r -I {} crictl rmi {} 2>/dev/null || true" || true',
'docker exec k3d-unity-builder-server-0 sh -c "crictl images --format \\"{{.Repository}}:{{.Tag}}\\" 2>/dev/null | grep -vE \\"unityci/editor|unity\\" | grep -E \\"rancher/|curlimages/|amazon/aws-cli|rclone/rclone|steamcmd/steamcmd|ubuntu:|alpine:\\" | xargs -r -I {} crictl rmi {} 2>/dev/null || true" || true',
// DO NOT use --prune as it might remove the Unity image if no containers are using it
// Only clean up if we have very little space left
// DO NOT remove images - preserve everything including Unity image
// Removing images risks removing the Unity image which causes "no space left" errors
];
for (const cmd of cleanupCommands) {
try {
@ -3783,10 +3779,18 @@ class Kubernetes {
cloud_runner_logger_1.default.log(`Cleanup command failed (non-fatal): ${cmdError}`);
}
}
// Verify Unity image is still cached
// Verify Unity image is still cached - if not found, log warning but continue
// The image might be on the server node instead of agent node
try {
const unityImageCheck = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in agent'" || true`, true, true);
cloud_runner_logger_1.default.log(`Unity image cache status:\n${unityImageCheck}`);
const unityImageCheckAgent = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in agent'" || true`, true, true);
const unityImageCheckServer = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-server-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in server'" || true`, true, true);
cloud_runner_logger_1.default.log(`Unity image cache status - Agent:\n${unityImageCheckAgent}`);
cloud_runner_logger_1.default.log(`Unity image cache status - Server:\n${unityImageCheckServer}`);
// If image is not found in either node, log a warning
if (unityImageCheckAgent.includes('not found') &&
unityImageCheckServer.includes('not found')) {
cloud_runner_logger_1.default.logWarning('Unity image not found in k3d nodes. It will need to be pulled, which may cause disk space issues.');
}
}
catch {
// Ignore check failures

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -167,19 +167,15 @@ class Kubernetes implements ProviderInterface {
const imageName = image.split(':')[0];
const imageTag = image.split(':')[1] || 'latest';
// More targeted cleanup: remove stopped containers and non-Unity images
// IMPORTANT: Preserve Unity images to avoid re-pulling the 3.9GB image
// Strategy: Only remove containers, don't prune images (which might remove Unity image)
// More targeted cleanup: remove stopped containers only
// IMPORTANT: Do NOT remove images - preserve Unity image to avoid re-pulling the 3.9GB image
// Strategy: Only remove containers, never touch images (safest approach)
const cleanupCommands = [
// Remove all stopped containers (this frees runtime space but keeps images)
'docker exec k3d-unity-builder-agent-0 sh -c "crictl rm --all 2>/dev/null || true" || true',
'docker exec k3d-unity-builder-server-0 sh -c "crictl rm --all 2>/dev/null || true" || true',
// Remove specific non-Unity images by name (safer than filtering)
// Only remove known system images, preserve everything else including Unity
'docker exec k3d-unity-builder-agent-0 sh -c "crictl images --format \\"{{.Repository}}:{{.Tag}}\\" 2>/dev/null | grep -vE \\"unityci/editor|unity\\" | grep -E \\"rancher/|curlimages/|amazon/aws-cli|rclone/rclone|steamcmd/steamcmd|ubuntu:|alpine:\\" | xargs -r -I {} crictl rmi {} 2>/dev/null || true" || true',
'docker exec k3d-unity-builder-server-0 sh -c "crictl images --format \\"{{.Repository}}:{{.Tag}}\\" 2>/dev/null | grep -vE \\"unityci/editor|unity\\" | grep -E \\"rancher/|curlimages/|amazon/aws-cli|rclone/rclone|steamcmd/steamcmd|ubuntu:|alpine:\\" | xargs -r -I {} crictl rmi {} 2>/dev/null || true" || true',
// DO NOT use --prune as it might remove the Unity image if no containers are using it
// Only clean up if we have very little space left
// DO NOT remove images - preserve everything including Unity image
// Removing images risks removing the Unity image which causes "no space left" errors
];
for (const cmd of cleanupCommands) {
@ -191,14 +187,31 @@ class Kubernetes implements ProviderInterface {
}
}
// Verify Unity image is still cached
// Verify Unity image is still cached - if not found, log warning but continue
// The image might be on the server node instead of agent node
try {
const unityImageCheck = await CloudRunnerSystem.Run(
const unityImageCheckAgent = await CloudRunnerSystem.Run(
`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in agent'" || true`,
true,
true,
);
CloudRunnerLogger.log(`Unity image cache status:\n${unityImageCheck}`);
const unityImageCheckServer = await CloudRunnerSystem.Run(
`docker exec k3d-unity-builder-server-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in server'" || true`,
true,
true,
);
CloudRunnerLogger.log(`Unity image cache status - Agent:\n${unityImageCheckAgent}`);
CloudRunnerLogger.log(`Unity image cache status - Server:\n${unityImageCheckServer}`);
// If image is not found in either node, log a warning
if (
unityImageCheckAgent.includes('not found') &&
unityImageCheckServer.includes('not found')
) {
CloudRunnerLogger.logWarning(
'Unity image not found in k3d nodes. It will need to be pulled, which may cause disk space issues.',
);
}
} catch {
// Ignore check failures
}

View File

@ -54,21 +54,15 @@ describe('Cloud Runner Retain Workspace', () => {
CloudRunnerLogger.log('Cleaning up k3d node between builds (preserving Unity image)...');
const K3D_NODE_CONTAINERS = ['k3d-unity-builder-agent-0', 'k3d-unity-builder-server-0'];
for (const NODE of K3D_NODE_CONTAINERS) {
// Remove stopped containers but keep images
// Remove stopped containers only - DO NOT touch images
// Removing images risks removing the Unity image which causes "no space left" errors
await CloudRunnerSystem.Run(
`docker exec ${NODE} sh -c "crictl rm --all 2>/dev/null || true" || true`,
true,
true,
);
// Only remove specific known system images, preserve Unity and everything else
// DO NOT use --prune as it might remove Unity image
await CloudRunnerSystem.Run(
`docker exec ${NODE} sh -c "crictl images --format '{{.Repository}}:{{.Tag}}' 2>/dev/null | grep -vE 'unityci/editor|unity' | grep -E 'rancher/|curlimages/|amazon/aws-cli|rclone/rclone|steamcmd/steamcmd|ubuntu:|alpine:' | xargs -r -I {} crictl rmi {} 2>/dev/null || true" || true`,
true,
true,
);
}
CloudRunnerLogger.log('Cleanup between builds completed');
CloudRunnerLogger.log('Cleanup between builds completed (containers removed, images preserved)');
} catch (cleanupError) {
CloudRunnerLogger.logWarning(`Failed to cleanup between builds: ${cleanupError}`);
// Continue anyway