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.
This commit is contained in:
parent
8d0da8c56b
commit
54bc4e0788
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
16
src/main.ts
16
src/main.ts
|
@ -307,7 +307,6 @@ actionsToolkit.run(
|
||||||
}
|
}
|
||||||
|
|
||||||
await core.group('Cleaning up Blacksmith builder', async () => {
|
await core.group('Cleaning up Blacksmith builder', async () => {
|
||||||
if (builderInfo.addr) {
|
|
||||||
try {
|
try {
|
||||||
let exportRes;
|
let exportRes;
|
||||||
if (!buildError) {
|
if (!buildError) {
|
||||||
|
@ -332,9 +331,19 @@ actionsToolkit.run(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.info('Unmounted device');
|
core.info('Unmounted device');
|
||||||
|
|
||||||
|
if (builderInfo.addr) {
|
||||||
if (!buildError) {
|
if (!buildError) {
|
||||||
await reporter.reportBuildCompleted(exportRes, builderInfo.buildId, ref, buildDurationSeconds, builderInfo.exposeId);
|
await reporter.reportBuildCompleted(exportRes, builderInfo.buildId, ref, buildDurationSeconds, builderInfo.exposeId);
|
||||||
} else {
|
} 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 {
|
try {
|
||||||
const buildkitdLog = fs.readFileSync('buildkitd.log', 'utf8');
|
const buildkitdLog = fs.readFileSync('buildkitd.log', 'utf8');
|
||||||
core.info('buildkitd.log contents:');
|
core.info('buildkitd.log contents:');
|
||||||
|
@ -342,11 +351,6 @@ actionsToolkit.run(
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.warning(`Failed to read buildkitd.log: ${error.message}`);
|
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
|
// Change permissions on the buildkitd socket to allow non-root access
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const timeout = 5000; // 5 seconds in milliseconds
|
const timeout = 10000; // 10 seconds in milliseconds
|
||||||
|
|
||||||
while (Date.now() - startTime < timeout) {
|
while (Date.now() - startTime < timeout) {
|
||||||
if (fs.existsSync('/run/buildkit/buildkitd.sock')) {
|
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')) {
|
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;
|
return buildkitdAddr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue