Skip to content

Commit adcdf1b

Browse files
committed
PR feedback
1 parent 2ecc14a commit adcdf1b

File tree

6 files changed

+123
-4
lines changed

6 files changed

+123
-4
lines changed

.github/workflows/cloud-runner-integrity.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ jobs:
7676
with:
7777
node-version: 20
7878
cache: 'yarn'
79+
- name: Clean up disk space before tests
80+
run: |
81+
# Clean up any leftover cache files from previous runs
82+
rm -rf ./cloud-runner-cache/* || true
83+
# Clean up system caches and temporary files
84+
sudo apt-get clean || true
85+
docker system prune -f || true
86+
# Show available disk space
87+
df -h
7988
- run: yarn install --frozen-lockfile
8089
- run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand
8190
timeout-minutes: 60
@@ -131,6 +140,15 @@ jobs:
131140
with:
132141
node-version: 20
133142
cache: 'yarn'
143+
- name: Clean up disk space before tests
144+
run: |
145+
# Clean up any leftover cache files from previous runs
146+
rm -rf ./cloud-runner-cache/* || true
147+
# Clean up system caches and temporary files
148+
sudo apt-get clean || true
149+
docker system prune -f || true
150+
# Show available disk space
151+
df -h
134152
- run: yarn install --frozen-lockfile
135153
- run: yarn run test "${{ matrix.test }}" --detectOpenHandles --forceExit --runInBand
136154
timeout-minutes: 60

dist/index.js

Lines changed: 36 additions & 2 deletions
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: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,43 @@ class KubernetesPods {
77
const phase = pods[0]?.status?.phase || 'undefined status';
88
CloudRunnerLogger.log(`Getting pod status: ${phase}`);
99
if (phase === `Failed`) {
10-
throw new Error(`K8s pod failed`);
10+
const pod = pods[0];
11+
const containerStatuses = pod.status?.containerStatuses || [];
12+
const conditions = pod.status?.conditions || [];
13+
const events = (await kubeClient.listNamespacedEvent(namespace)).body.items
14+
.filter((x) => x.involvedObject?.name === podName)
15+
.map((x) => ({
16+
message: x.message || '',
17+
reason: x.reason || '',
18+
type: x.type || '',
19+
}));
20+
21+
const errorDetails: string[] = [];
22+
errorDetails.push(`Pod: ${podName}`);
23+
errorDetails.push(`Phase: ${phase}`);
24+
25+
if (conditions.length > 0) {
26+
errorDetails.push(`Conditions: ${JSON.stringify(conditions.map(c => ({ type: c.type, status: c.status, reason: c.reason, message: c.message })), undefined, 2)}`);
27+
}
28+
29+
if (containerStatuses.length > 0) {
30+
containerStatuses.forEach((cs, idx) => {
31+
if (cs.state?.waiting) {
32+
errorDetails.push(`Container ${idx} (${cs.name}) waiting: ${cs.state.waiting.reason} - ${cs.state.waiting.message || ''}`);
33+
}
34+
if (cs.state?.terminated) {
35+
errorDetails.push(`Container ${idx} (${cs.name}) terminated: ${cs.state.terminated.reason} - ${cs.state.terminated.message || ''} (exit code: ${cs.state.terminated.exitCode})`);
36+
}
37+
});
38+
}
39+
40+
if (events.length > 0) {
41+
errorDetails.push(`Recent events: ${JSON.stringify(events.slice(-5), undefined, 2)}`);
42+
}
43+
44+
const errorMessage = `K8s pod failed\n${errorDetails.join('\n')}`;
45+
CloudRunnerLogger.log(errorMessage);
46+
throw new Error(errorMessage);
1147
}
1248

1349
return running;

src/model/cloud-runner/tests/e2e/cloud-runner-end2end-caching.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,19 @@ describe('Cloud Runner Caching', () => {
8787
expect(build2NotContainsZeroLibraryCacheFilesMessage).toBeTruthy();
8888
expect(build2NotContainsZeroLFSCacheFilesMessage).toBeTruthy();
8989
}, 1_000_000_000);
90+
afterAll(async () => {
91+
// Clean up cache files to prevent disk space issues
92+
if (CloudRunnerOptions.providerStrategy === `local-docker` || CloudRunnerOptions.providerStrategy === `aws`) {
93+
const cachePath = `./cloud-runner-cache`;
94+
if (fs.existsSync(cachePath)) {
95+
try {
96+
CloudRunnerLogger.log(`Cleaning up cache directory: ${cachePath}`);
97+
await CloudRunnerSystem.Run(`rm -rf ${cachePath}/* || true`);
98+
} catch (error: any) {
99+
CloudRunnerLogger.log(`Failed to cleanup cache: ${error.message}`);
100+
}
101+
}
102+
}
103+
});
90104
}
91105
});

src/model/cloud-runner/tests/e2e/cloud-runner-end2end-retaining.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ describe('Cloud Runner Retain Workspace', () => {
8686
CloudRunnerLogger.log(
8787
`Cleaning up ./cloud-runner-cache/${path.basename(CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}`,
8888
);
89+
try {
90+
await CloudRunnerSystem.Run(
91+
`rm -rf ./cloud-runner-cache/${path.basename(CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)} || true`,
92+
);
93+
} catch (error: any) {
94+
CloudRunnerLogger.log(`Failed to cleanup workspace: ${error.message}`);
95+
}
96+
}
97+
// Clean up cache files to prevent disk space issues
98+
const cachePath = `./cloud-runner-cache`;
99+
if (fs.existsSync(cachePath)) {
100+
try {
101+
CloudRunnerLogger.log(`Cleaning up cache directory: ${cachePath}`);
102+
await CloudRunnerSystem.Run(`rm -rf ${cachePath}/* || true`);
103+
} catch (error: any) {
104+
CloudRunnerLogger.log(`Failed to cleanup cache: ${error.message}`);
105+
}
89106
}
90107
});
91108
}

0 commit comments

Comments
 (0)