Skip to content

Commit bea818f

Browse files
committed
PR feedback
1 parent 956b2e4 commit bea818f

File tree

4 files changed

+104
-5
lines changed

4 files changed

+104
-5
lines changed

dist/index.js

Lines changed: 48 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/cloud-runner/providers/k8s/kubernetes-pods.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ class KubernetesPods {
6363

6464
// Check if only PreStopHook failed but container succeeded
6565
const hasPreStopHookFailure = events.some((e) => e.reason === 'FailedPreStopHook');
66+
const wasKilled = events.some((e) => e.reason === 'Killing');
6667

68+
// If container succeeded (exit code 0), PreStopHook failure is non-critical
69+
// Also check if pod was killed but container might have succeeded
6770
if (containerSucceeded && containerExitCode === 0) {
6871
// Container succeeded - PreStopHook failure is non-critical
6972
if (hasPreStopHookFailure) {
@@ -79,6 +82,16 @@ class KubernetesPods {
7982
// Don't throw error - container succeeded, PreStopHook failure is non-critical
8083
return false; // Pod is not running, but we don't treat it as a failure
8184
}
85+
86+
// If pod was killed and we have PreStopHook failure but no container status yet, wait a bit
87+
// The container might have succeeded but status hasn't been updated yet
88+
if (wasKilled && hasPreStopHookFailure && containerExitCode === undefined) {
89+
CloudRunnerLogger.log(
90+
`Pod ${podName} was killed with PreStopHook failure, but container status not yet available. This may be non-fatal if container succeeded.`,
91+
);
92+
// Still throw error for now, but with more context
93+
// The task runner will retry and get the actual container status
94+
}
8295

8396
const errorMessage = `K8s pod failed\n${errorDetails.join('\n')}`;
8497
CloudRunnerLogger.log(errorMessage);

src/model/cloud-runner/remote-client/caching.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,48 @@ export class Caching {
7979
return;
8080
}
8181

82-
await CloudRunnerSystem.Run(
83-
`tar -cf ${cacheArtifactName}.tar${compressionSuffix} "${path.basename(sourceFolder)}"`,
84-
);
82+
// Check disk space before creating tar archive
83+
try {
84+
const diskCheckOutput = await CloudRunnerSystem.Run(`df -h . 2>/dev/null || df -h /data 2>/dev/null || true`);
85+
CloudRunnerLogger.log(`Disk space before tar: ${diskCheckOutput}`);
86+
} catch (error) {
87+
// Ignore disk check errors
88+
}
89+
90+
// Clean up any existing incomplete tar files
91+
try {
92+
await CloudRunnerSystem.Run(`rm -f ${cacheArtifactName}.tar${compressionSuffix} 2>/dev/null || true`);
93+
} catch (error) {
94+
// Ignore cleanup errors
95+
}
96+
97+
try {
98+
await CloudRunnerSystem.Run(
99+
`tar -cf ${cacheArtifactName}.tar${compressionSuffix} "${path.basename(sourceFolder)}"`,
100+
);
101+
} catch (error: any) {
102+
// Check if error is due to disk space
103+
const errorMessage = error?.message || error?.toString() || '';
104+
if (errorMessage.includes('No space left') || errorMessage.includes('Wrote only')) {
105+
CloudRunnerLogger.log(`Disk space error detected. Attempting cleanup...`);
106+
// Try to clean up old cache files
107+
try {
108+
const cacheParent = path.dirname(cacheFolder);
109+
if (await fileExists(cacheParent)) {
110+
// Find and remove old cache entries (keep only the most recent)
111+
await CloudRunnerSystem.Run(
112+
`find ${cacheParent} -name "*.tar*" -type f -mtime +1 -delete 2>/dev/null || true`,
113+
);
114+
}
115+
} catch (cleanupError) {
116+
CloudRunnerLogger.log(`Cleanup attempt failed: ${cleanupError}`);
117+
}
118+
throw new Error(
119+
`Failed to create cache archive due to insufficient disk space. Error: ${errorMessage}. Please free up disk space and retry.`,
120+
);
121+
}
122+
throw error;
123+
}
85124
await CloudRunnerSystem.Run(`du ${cacheArtifactName}.tar${compressionSuffix}`);
86125
assert(await fileExists(`${cacheArtifactName}.tar${compressionSuffix}`), 'cache archive exists');
87126
assert(await fileExists(path.basename(sourceFolder)), 'source folder exists');

0 commit comments

Comments
 (0)