From 21ea72fa32ea375476ff4d57a870920c27c1e385 Mon Sep 17 00:00:00 2001 From: Eythor Magnusson Date: Tue, 10 Oct 2023 20:44:48 +0200 Subject: [PATCH] improvement(core): log stderr from exec as info Before this change, we logged stderr streams from init scripts as errors but now we log it at the info level. The reason is that some tools, e.g. gcloud, write to stderr even if it's not an actual error. In the case of an actual error the script exits with a non-zero code and that's handled specifically. So this is really just a cosmetic change to how exec provider logs are rendered. --- core/src/util/util.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/util/util.ts b/core/src/util/util.ts index 5ca8a04668..94c69862b9 100644 --- a/core/src/util/util.ts +++ b/core/src/util/util.ts @@ -667,7 +667,14 @@ export async function runScript({ log.error(line.toString()) }) errorStream.on("data", (line: Buffer) => { - log.error(line.toString()) + // NOTE: We're intentionally logging stderr streams at the "info" level + // because some tools will write to stderr even if it's not an actual error. + // So rendering it as such will look confusing to the user. + // An example of this is the gcloud CLI tool. If run from e.g. the exec + // provider init script, Garden would log those lines as errors if we don't + // use the info level here. + // Actual error are handled specifically. + log.info(line.toString()) }) // Workaround for https://github.com/vercel/pkg/issues/897 env.PKG_EXECPATH = ""