pr feedback

cloud-runner-develop
Frostebite 2026-01-17 19:45:47 +00:00
parent 828e65bdd7
commit b470780639
3 changed files with 111 additions and 49 deletions

62
dist/index.js vendored
View File

@ -3779,29 +3779,34 @@ class Kubernetes {
cloud_runner_logger_1.default.log(`Cleanup command failed (non-fatal): ${cmdError}`); cloud_runner_logger_1.default.log(`Cleanup command failed (non-fatal): ${cmdError}`);
} }
} }
// Verify Unity image is still cached - if not found, log warning but continue // Verify Unity image is cached on the AGENT node (where pods run)
// The image might be on the server node instead of agent node // This is critical - if the image isn't on the agent node, pods will try to pull it
let unityImageCached = false;
try { try {
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 unityImageCheckAgent = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep -q unityci/editor && echo 'found' || echo 'not found'" || echo 'not found'`, 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); unityImageCached = unityImageCheckAgent.includes('found');
cloud_runner_logger_1.default.log(`Unity image cache status - Agent:\n${unityImageCheckAgent}`); cloud_runner_logger_1.default.log(`Unity image cache status on agent node: ${unityImageCached ? 'CACHED' : 'NOT CACHED'}`);
cloud_runner_logger_1.default.log(`Unity image cache status - Server:\n${unityImageCheckServer}`); if (!unityImageCached) {
// If image is not found in either node, log a warning // Check if it's on the server node (might need to be copied)
if (unityImageCheckAgent.includes('not found') && const unityImageCheckServer = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-server-0 sh -c "crictl images | grep -q unityci/editor && echo 'found' || echo 'not found'" || echo 'not found'`, true, true);
unityImageCheckServer.includes('not found')) { cloud_runner_logger_1.default.log(`Unity image cache status on server node: ${unityImageCheckServer.includes('found') ? 'CACHED' : 'NOT CACHED'}`);
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.'); // Check available disk space
const diskCheck = await CloudRunnerSystem.Run('docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null | tail -1 | awk \'{print $4}\' || df -h / 2>/dev/null | tail -1 | awk \'{print $4}\' || echo unknown" || echo unknown', true, true);
cloud_runner_logger_1.default.log(`Available disk space on agent node: ${diskCheck.trim()}`);
// Unity image is ~3.9GB, so we need at least 4-5GB free
// If we have less than 4GB, warn that pull will likely fail
const availableSpaceStr = diskCheck.trim().toLowerCase();
if (availableSpaceStr.includes('g')) {
const availableGB = parseFloat(availableSpaceStr);
if (availableGB < 4) {
cloud_runner_logger_1.default.logWarning(`WARNING: Unity image not cached and only ${availableGB}GB available. Image pull (3.9GB) will likely fail due to disk pressure.`);
}
}
} }
} }
catch { catch {
// Ignore check failures // Ignore check failures - continue and hope image is cached
} cloud_runner_logger_1.default.logWarning('Failed to check Unity image cache status');
// Check disk space after cleanup
try {
const diskCheck = await CloudRunnerSystem.Run('docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null || df -h / 2>/dev/null || true" || true', true, true);
cloud_runner_logger_1.default.log(`Disk space in k3d node after cleanup:\n${diskCheck}`);
}
catch {
// Ignore disk check failures
} }
} }
catch (cleanupError) { catch (cleanupError) {
@ -3811,6 +3816,25 @@ class Kubernetes {
} }
let output = ''; let output = '';
try { try {
// Before creating the job, verify we have the Unity image cached or enough space to pull it
if (process.env['cloudRunnerTests'] === 'true' && image.includes('unityci/editor')) {
try {
const { CloudRunnerSystem } = await Promise.resolve().then(() => __importStar(__nccwpck_require__(4197)));
const imageCheck = await CloudRunnerSystem.Run(`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep -q unityci/editor && echo 'cached' || echo 'not_cached'" || echo 'not_cached'`, true, true);
if (imageCheck.includes('not_cached')) {
// Image not cached - check if we have enough space to pull it
const diskInfo = await CloudRunnerSystem.Run('docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null | tail -1 || df -h / 2>/dev/null | tail -1 || echo unknown" || echo unknown', true, true);
cloud_runner_logger_1.default.logWarning(`Unity image not cached on agent node. Disk info: ${diskInfo.trim()}. Pod will attempt to pull image (3.9GB) which may fail due to disk pressure.`);
}
else {
cloud_runner_logger_1.default.log('Unity image is cached on agent node - pod should start without pulling');
}
}
catch (checkError) {
// Ignore check errors - continue with job creation
cloud_runner_logger_1.default.logWarning(`Failed to verify Unity image cache: ${checkError}`);
}
}
cloud_runner_logger_1.default.log('Job does not exist'); cloud_runner_logger_1.default.log('Job does not exist');
await this.createJob(commands, image, mountdir, workingdir, environment, secrets); await this.createJob(commands, image, mountdir, workingdir, environment, secrets);
cloud_runner_logger_1.default.log('Watching pod until running'); cloud_runner_logger_1.default.log('Watching pod until running');

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -187,45 +187,54 @@ class Kubernetes implements ProviderInterface {
} }
} }
// Verify Unity image is still cached - if not found, log warning but continue // Verify Unity image is cached on the AGENT node (where pods run)
// The image might be on the server node instead of agent node // This is critical - if the image isn't on the agent node, pods will try to pull it
let unityImageCached = false;
try { try {
const unityImageCheckAgent = 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`, `docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep -q unityci/editor && echo 'found' || echo 'not found'" || echo 'not found'`,
true, true,
true, true,
); );
const unityImageCheckServer = await CloudRunnerSystem.Run( unityImageCached = unityImageCheckAgent.includes('found');
`docker exec k3d-unity-builder-server-0 sh -c "crictl images | grep unityci/editor || echo 'Unity image not found in server'" || true`, CloudRunnerLogger.log(
true, `Unity image cache status on agent node: ${unityImageCached ? 'CACHED' : 'NOT CACHED'}`,
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 (!unityImageCached) {
if ( // Check if it's on the server node (might need to be copied)
unityImageCheckAgent.includes('not found') && const unityImageCheckServer = await CloudRunnerSystem.Run(
unityImageCheckServer.includes('not found') `docker exec k3d-unity-builder-server-0 sh -c "crictl images | grep -q unityci/editor && echo 'found' || echo 'not found'" || echo 'not found'`,
) { true,
CloudRunnerLogger.logWarning( true,
'Unity image not found in k3d nodes. It will need to be pulled, which may cause disk space issues.',
); );
CloudRunnerLogger.log(
`Unity image cache status on server node: ${unityImageCheckServer.includes('found') ? 'CACHED' : 'NOT CACHED'}`,
);
// Check available disk space
const diskCheck = await CloudRunnerSystem.Run(
'docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null | tail -1 | awk \'{print $4}\' || df -h / 2>/dev/null | tail -1 | awk \'{print $4}\' || echo unknown" || echo unknown',
true,
true,
);
CloudRunnerLogger.log(`Available disk space on agent node: ${diskCheck.trim()}`);
// Unity image is ~3.9GB, so we need at least 4-5GB free
// If we have less than 4GB, warn that pull will likely fail
const availableSpaceStr = diskCheck.trim().toLowerCase();
if (availableSpaceStr.includes('g')) {
const availableGB = parseFloat(availableSpaceStr);
if (availableGB < 4) {
CloudRunnerLogger.logWarning(
`WARNING: Unity image not cached and only ${availableGB}GB available. Image pull (3.9GB) will likely fail due to disk pressure.`,
);
}
}
} }
} catch { } catch {
// Ignore check failures // Ignore check failures - continue and hope image is cached
} CloudRunnerLogger.logWarning('Failed to check Unity image cache status');
// Check disk space after cleanup
try {
const diskCheck = await CloudRunnerSystem.Run(
'docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null || df -h / 2>/dev/null || true" || true',
true,
true,
);
CloudRunnerLogger.log(`Disk space in k3d node after cleanup:\n${diskCheck}`);
} catch {
// Ignore disk check failures
} }
} catch (cleanupError) { } catch (cleanupError) {
CloudRunnerLogger.logWarning(`Failed to cleanup images before job creation: ${cleanupError}`); CloudRunnerLogger.logWarning(`Failed to cleanup images before job creation: ${cleanupError}`);
@ -235,6 +244,35 @@ class Kubernetes implements ProviderInterface {
let output = ''; let output = '';
try { try {
// Before creating the job, verify we have the Unity image cached or enough space to pull it
if (process.env['cloudRunnerTests'] === 'true' && image.includes('unityci/editor')) {
try {
const { CloudRunnerSystem } = await import('../../services/core/cloud-runner-system');
const imageCheck = await CloudRunnerSystem.Run(
`docker exec k3d-unity-builder-agent-0 sh -c "crictl images | grep -q unityci/editor && echo 'cached' || echo 'not_cached'" || echo 'not_cached'`,
true,
true,
);
if (imageCheck.includes('not_cached')) {
// Image not cached - check if we have enough space to pull it
const diskInfo = await CloudRunnerSystem.Run(
'docker exec k3d-unity-builder-agent-0 sh -c "df -h /var/lib/rancher/k3s 2>/dev/null | tail -1 || df -h / 2>/dev/null | tail -1 || echo unknown" || echo unknown',
true,
true,
);
CloudRunnerLogger.logWarning(
`Unity image not cached on agent node. Disk info: ${diskInfo.trim()}. Pod will attempt to pull image (3.9GB) which may fail due to disk pressure.`,
);
} else {
CloudRunnerLogger.log('Unity image is cached on agent node - pod should start without pulling');
}
} catch (checkError) {
// Ignore check errors - continue with job creation
CloudRunnerLogger.logWarning(`Failed to verify Unity image cache: ${checkError}`);
}
}
CloudRunnerLogger.log('Job does not exist'); CloudRunnerLogger.log('Job does not exist');
await this.createJob(commands, image, mountdir, workingdir, environment, secrets); await this.createJob(commands, image, mountdir, workingdir, environment, secrets);
CloudRunnerLogger.log('Watching pod until running'); CloudRunnerLogger.log('Watching pod until running');