src: refactor cleanup logic to expose buildkitd.log

Previosuly, we only killed the buildkitd process and unmounted
if builderInfo was non null. This was wrong cause we could have setup
builkdkitd, but failed after that step. This would then rely on the last
ditch effort by the post action to cleanup. We now change the proc kill
and unmount to happen on any build error.
pull/1358/head
Aditya Maru 1 year ago
parent 8d0da8c56b
commit 54bc4e0788

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

@ -307,7 +307,6 @@ actionsToolkit.run(
}
await core.group('Cleaning up Blacksmith builder', async () => {
if (builderInfo.addr) {
try {
let exportRes;
if (!buildError) {
@ -332,9 +331,19 @@ actionsToolkit.run(
}
}
core.info('Unmounted device');
if (builderInfo.addr) {
if (!buildError) {
await reporter.reportBuildCompleted(exportRes, builderInfo.buildId, ref, buildDurationSeconds, builderInfo.exposeId);
} else {
await reporter.reportBuildFailed(builderInfo.buildId, buildDurationSeconds, builderInfo.exposeId);
}
}
} catch (error) {
core.warning(`Error during Blacksmith builder shutdown: ${error.message}`);
await reporter.reportBuildPushActionFailure(error);
} finally {
if (buildError) {
try {
const buildkitdLog = fs.readFileSync('buildkitd.log', 'utf8');
core.info('buildkitd.log contents:');
@ -342,11 +351,6 @@ actionsToolkit.run(
} catch (error) {
core.warning(`Failed to read buildkitd.log: ${error.message}`);
}
await reporter.reportBuildFailed(builderInfo.buildId, buildDurationSeconds, builderInfo.exposeId);
}
} catch (error) {
core.warning(`Error during Blacksmith builder shutdown: ${error.message}`);
await reporter.reportBuildPushActionFailure(error);
}
}
});

@ -177,7 +177,7 @@ export async function startAndConfigureBuildkitd(parallelism: number, device: st
// Change permissions on the buildkitd socket to allow non-root access
const startTime = Date.now();
const timeout = 5000; // 5 seconds in milliseconds
const timeout = 10000; // 10 seconds in milliseconds
while (Date.now() - startTime < timeout) {
if (fs.existsSync('/run/buildkit/buildkitd.sock')) {
@ -189,7 +189,7 @@ export async function startAndConfigureBuildkitd(parallelism: number, device: st
}
if (!fs.existsSync('/run/buildkit/buildkitd.sock')) {
throw new Error('buildkitd socket not found after 5s timeout');
throw new Error('buildkitd socket not found after 10s timeout');
}
return buildkitdAddr;
}

Loading…
Cancel
Save