From 67f3f8361038a4cf223b39c8c221cb7bab24f975 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 3 Dec 2020 14:56:32 +0200 Subject: [PATCH] Performance fix when cluster has lots of namespaces (#1640) * performance fix when cluster has lots of namespaces Signed-off-by: Jari Kolehmainen * fix tests Signed-off-by: Jari Kolehmainen --- src/main/__test__/cluster.test.ts | 7 ------- src/main/cluster.ts | 11 +---------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/main/__test__/cluster.test.ts b/src/main/__test__/cluster.test.ts index 20e56c8b84..b3f0442cc2 100644 --- a/src/main/__test__/cluster.test.ts +++ b/src/main/__test__/cluster.test.ts @@ -127,13 +127,6 @@ describe("create clusters", () => { jest.spyOn(Cluster.prototype, "isClusterAdmin").mockReturnValue(Promise.resolve(true)); jest.spyOn(Cluster.prototype, "canI") - .mockImplementationOnce((attr: V1ResourceAttributes): Promise => { - expect(attr.namespace).toBe("default"); - expect(attr.resource).toBe("pods"); - expect(attr.verb).toBe("list"); - - return Promise.resolve(true); - }) .mockImplementation((attr: V1ResourceAttributes): Promise => { expect(attr.namespace).toBe("default"); expect(attr.verb).toBe("list"); diff --git a/src/main/cluster.ts b/src/main/cluster.ts index 421856dc03..a130691e8e 100644 --- a/src/main/cluster.ts +++ b/src/main/cluster.ts @@ -425,17 +425,8 @@ export class Cluster implements ClusterModel, ClusterState { try { const namespaceList = await api.listNamespace(); - const nsAccessStatuses = await Promise.all( - namespaceList.body.items.map(ns => this.canI({ - namespace: ns.metadata.name, - resource: "pods", - verb: "list", - })) - ); - return namespaceList.body.items - .filter((ns, i) => nsAccessStatuses[i]) - .map(ns => ns.metadata.name); + return namespaceList.body.items.map(ns => ns.metadata.name); } catch (error) { const ctx = this.getProxyKubeconfig().getContextObject(this.contextName);