mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-13 09:23:52 -07:00
fix
This commit is contained in:
+14
-13
@@ -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}`);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user