docker(install): print lima logs on "colima start" failure

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-08-31 03:10:23 +02:00
parent 31d5e42cc0
commit 7b72d5977b

View File

@@ -16,6 +16,7 @@
import * as child_process from 'child_process';
import fs from 'fs';
import fsp from 'fs/promises';
import os from 'os';
import path from 'path';
import retry from 'async-retry';
@@ -187,10 +188,23 @@ export class Install {
try {
await Exec.exec(`colima ${colimaStartArgs.join(' ')}`, [], {env: envs});
} catch (e) {
const haStderrLog = path.join(os.homedir(), '.lima', 'colima', 'ha.stderr.log');
if (fs.existsSync(haStderrLog)) {
core.info(`Printing debug logs (${haStderrLog}):\n${fs.readFileSync(haStderrLog, {encoding: 'utf8'})}`);
}
const limaColimaDir = path.join(os.homedir(), '.lima', 'colima');
fsp
.readdir(limaColimaDir)
.then(files => {
files
.filter(f => path.extname(f) === '.log')
.forEach(f => {
const logfile = path.join(limaColimaDir, f);
const logcontent = fs.readFileSync(logfile, {encoding: 'utf8'}).trim();
if (logcontent.length > 0) {
core.info(`### ${logfile}:\n${logcontent}`);
}
});
})
.catch(() => {
// ignore
});
throw e;
}
});