This commit is contained in:
Frostebite
2026-01-20 05:58:11 +00:00
parent 9aa24e21f1
commit b2cb6ebb19
5 changed files with 138 additions and 28 deletions
Generated Vendored
+14 -13
View File
@@ -3757,28 +3757,29 @@ class Kubernetes {
try {
cloud_runner_logger_1.default.log('Cleaning up old images in k3d node before pulling new image...');
const { CloudRunnerSystem } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(4197)));
// Extract image name without tag for matching
const imageName = image.split(':')[0];
const imageTag = image.split(':')[1] || 'latest';
// 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 = [
// Aggressive cleanup: remove stopped containers and non-Unity images
// IMPORTANT: Preserve Unity images (unityci/editor) to avoid re-pulling the 3.9GB image
const K3D_NODE_CONTAINERS = ['k3d-unity-builder-agent-0', 'k3d-unity-builder-server-0'];
const cleanupCommands = [];
for (const NODE of K3D_NODE_CONTAINERS) {
// 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',
// DO NOT remove images - preserve everything including Unity image
// Removing images risks removing the Unity image which causes "no space left" errors
];
cleanupCommands.push(`docker exec ${NODE} sh -c "crictl rm --all 2>/dev/null || true" || true`);
// Remove non-Unity images only (preserve unityci/editor images to avoid re-pulling 3.9GB)
// This is safe because we explicitly exclude Unity images from deletion
cleanupCommands.push(`docker exec ${NODE} sh -c "for img in \$(crictl images -q 2>/dev/null); do repo=\$(crictl inspecti \$img --format '{{.repo}}' 2>/dev/null || echo ''); if echo \"\$repo\" | grep -qvE 'unityci/editor|unity'; then crictl rmi \$img 2>/dev/null || true; fi; done" || true`);
// Clean up unused layers (prune should preserve referenced images)
cleanupCommands.push(`docker exec ${NODE} sh -c "crictl rmi --prune 2>/dev/null || true" || true`);
}
for (const cmd of cleanupCommands) {
try {
await CloudRunnerSystem.Run(cmd, true, true);
}
catch (cmdError) {
// Ignore individual command failures
// Ignore individual command failures - cleanup is best effort
cloud_runner_logger_1.default.log(`Cleanup command failed (non-fatal): ${cmdError}`);
}
}
cloud_runner_logger_1.default.log('Cleanup completed (containers and non-Unity images removed, Unity images preserved)');
}
catch (cleanupError) {
cloud_runner_logger_1.default.logWarning(`Failed to cleanup images before job creation: ${cleanupError}`);
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long