Fix Cluster.refresh sometimes taking upwards of 20s (#4826)

- Only read and parse the proxy config once

- Reuse the AuthorizationV1Api instance for the entire refresh instead
  of recreating it between 32 and 302 times, this should allow for
  reusing sockets

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-02-08 15:37:46 +02:00
1 parent 4abe0d6c20
commit 0745f9c063
6 files changed
+118 -73

No files matched your search

@@ -3,21 +3,22 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { ClusterModel } from "../../common/cluster-types";
import { Cluster } from "../../common/cluster/cluster";
import { Cluster, ClusterDependencies } from "../../common/cluster/cluster";
import directoryForKubeConfigsInjectable from "../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
import { createClusterInjectionToken } from "../../common/cluster/create-cluster-injection-token";
const createClusterInjectable = getInjectable({
instantiate: (di) => {
const dependencies = {
const dependencies: ClusterDependencies = {
directoryForKubeConfigs: di.inject(directoryForKubeConfigsInjectable),
createKubeconfigManager: () => { throw new Error("Tried to access back-end feature in front-end."); },
createKubectl: () => { throw new Error("Tried to access back-end feature in front-end.");},
createContextHandler: () => { throw new Error("Tried to access back-end feature in front-end."); },
createAuthorizationReview: () => { throw new Error("Tried to access back-end feature in front-end."); },
createListNamespaces: () => { throw new Error("Tried to access back-end feature in front-end."); },
};
return (model: ClusterModel) => new Cluster(dependencies, model);
return (model) => new Cluster(dependencies, model);
},
injectionToken: createClusterInjectionToken,