Skip to content

Commit

Permalink
Merge pull request #161 from crazy-max/colima-error-logs
Browse files Browse the repository at this point in the history
docker(install): print lima logs on "colima start" failure
  • Loading branch information
crazy-max authored Sep 6, 2023
2 parents 66fff01 + 7b72d59 commit c73f530
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/docker/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
});
Expand Down

0 comments on commit c73f530

Please sign in to comment.