From 7b72d5977b6e2c83df834b8b1d78038ecaece7a3 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Thu, 31 Aug 2023 03:10:23 +0200 Subject: [PATCH] docker(install): print lima logs on "colima start" failure Signed-off-by: CrazyMax --- src/docker/install.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/docker/install.ts b/src/docker/install.ts index 512b6d5..5984bc1 100644 --- a/src/docker/install.ts +++ b/src/docker/install.ts @@ -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; } });