From 5249a8ebedff41d2437a4113e10f153d77f6c292 Mon Sep 17 00:00:00 2001 From: Michael Pearson Date: Thu, 18 Aug 2022 22:21:24 +1000 Subject: [PATCH] Don't error out if we can't find resources from helm in our cluster, and handle "blank" output from kubectl gracefully. (#6039) --- src/main/helm/helm-release-manager.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/helm/helm-release-manager.ts b/src/main/helm/helm-release-manager.ts index 4c6e974152..f0907dc3c2 100644 --- a/src/main/helm/helm-release-manager.ts +++ b/src/main/helm/helm-release-manager.ts @@ -194,6 +194,11 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str "--kubeconfig", kubeconfigPath, "-f", "-", "--output", "json", + // Temporary workaround for https://github.com/lensapp/lens/issues/6031 + // and other potential issues where resources can't be found. Showing + // no resources is better than the app hard-locking, and at least + // the helm metadata is shown. + "--ignore-not-found", ]; try { @@ -208,9 +213,13 @@ async function getResources(name: string, namespace: string, kubeconfigPath: str .on("exit", (code, signal) => { if (typeof code === "number") { if (code === 0) { - const output = json.parse(stdout) as { items: JsonObject[] }; + if (stdout === "") { + resolve([]); + } else { + const output = json.parse(stdout) as { items: JsonObject[] }; - resolve(output.items); + resolve(output.items); + } } else { reject(stderr); }