From 72bedbe9f1df0c92d966b2d679aaed85a1e98d02 Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Thu, 26 Sep 2024 12:14:14 +0300 Subject: [PATCH] fix(dashmate): doctor fails collecting to big logs (#2158) --- packages/dashmate/src/docker/DockerCompose.js | 16 +++++++++++++--- .../tasks/doctor/collectSamplesTaskFactory.js | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/dashmate/src/docker/DockerCompose.js b/packages/dashmate/src/docker/DockerCompose.js index c9231128be..8a50800805 100644 --- a/packages/dashmate/src/docker/DockerCompose.js +++ b/packages/dashmate/src/docker/DockerCompose.js @@ -487,13 +487,23 @@ export default class DockerCompose { * Logs * * @param {Config} config - * @return {Promise} + * @param {string[]} services + * @param {Object} options + * @param {number} options.tail + * @return {Promise<{exitCode: number | null, out: string, err: string}>} */ - async logs(config, services = []) { + async logs(config, services = [], options = {}) { await this.throwErrorIfNotInstalled(); + const args = [...services]; + if (options.tail) { + args.unshift('--tail', options.tail.toString()); + } + + const commandOptions = this.#createOptions(config); + try { - return dockerCompose.logs(services, this.#createOptions(config)); + return await dockerCompose.logs(args, commandOptions); } catch (e) { throw new DockerComposeError(e); } diff --git a/packages/dashmate/src/listr/tasks/doctor/collectSamplesTaskFactory.js b/packages/dashmate/src/listr/tasks/doctor/collectSamplesTaskFactory.js index 1c4d7540be..8e4ae5794a 100644 --- a/packages/dashmate/src/listr/tasks/doctor/collectSamplesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/doctor/collectSamplesTaskFactory.js @@ -323,7 +323,7 @@ export default function collectSamplesTaskFactory( services.map(async (service) => { const [inspect, logs] = (await Promise.allSettled([ dockerCompose.inspectService(config, service.name), - dockerCompose.logs(config, [service.name]), + dockerCompose.logs(config, [service.name], { tail: 300000 }), ])).map((e) => e.value || e.reason); if (logs?.out) {